我想强迫我的用户使用https登录.不幸的是,"redirect"指令似乎不能在"ProxyPass"的cunjunction中工作
<VirtualHost *:80>
ServerName www.domain.com
# This does not work
Redirect permanent /app/login.jsp https://www.domain.com/app/login.jsp
ProxyPass /app http://localhost:8080/app
ProxyPassReverse /app http://localhost:8080/app
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?谢谢.
小智 8
在这里找到这个问题的答案:
https://serverfault.com/questions/605931/can-you-use-redirect-and-proxypass-at-the-same-time
在其他proxypass指令之前需要添加以下内容:
ProxyPass /app/login.jsp!
我有一个更复杂的用例,它需要使用ProxyPassMatch.它有点像这样:
ProxyPassMatch ^/app(/(index.html)?)?$ !
RedirectMatch ^/app(/(index.html)?)?$ /path/to/login/page.html
ProxyPass /app/* http://remote-server/app
ProxyPassReverse /app/* http://remote-server/app
Run Code Online (Sandbox Code Playgroud)
我不得不使用,ProxyPassMatch因为ProxyPass否则执行前缀匹配.您需要匹配字符串结尾,因此ProxyPassMatch使用$正则表达式元字符是至关重要的.
这里RedirectMatch使用的方式相同,因为它Redirect也执行前缀匹配.这两个指令也具有良好的对称性.
ProxyPass正如您所指出的,您有一个for 位置这一事实/app意味着到达该路径的任何内容都将受到代理的影响。
您可以省略使用并使用 a和代理标志ProxyPass进行代理:RewriteRule[P]
<VirtualHost *:80>
ServerName www.domain.com
RewriteRule ^/(app/login.jsp)$ https://www.domain.com/$1 [R=301,L]
RewriteRule ^/app(.*) http://localhost:8080/app$1 [P]
ProxyPassReverse /app http://localhost:8080/app
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19227 次 |
| 最近记录: |