我有一个工作配置,看起来
ProxyPass /roundcube protocol://127.0.0.1:8080/roundcube
ProxyPassReverse /roundcube protocol://127.0.0.1:8080/roundcube
当我去
http://www.example.com/roundcube
or
https://www.example.com/roundcube
与预期一样,在127.0.0.1:8080上都或正确地代理到服务器。
但是,我希望更多地控制代理发生的时间,所以我希望使用mod_rewrite的P选项,而不是上面所示的ProxyPass指令。我尝试了以下几点:
RewriteEngine On
RewriteRule ^/roundcube$ /roundcube/ [R]
RewriteRule ^/roundcube/(.*) protocol://127.0.0.1:8080/roundcube/$1 [P]
ProxyPassReverse /roundcube protocol://127.0.0.1:8080/roundcube
有了这个配置,当我进入
http://www.example.com/roundcube
请求代理与预期一样正确。
但当我去
https://www.example.com/roundcube
请求404号。
所以我的问题是,为什么mod_rewrite代理在http和https请求方面不像ProxyPass版本那样工作呢?根据我的理解,我上面的两个例子在功能上应该是等价的,但情况似乎并非如此。我遗漏了什么?我还没有找到任何可以解释这一点的文档。谢谢!
发布于 2015-08-13 05:07:19
尽管为时已晚,但我会发布这个答案,以防有人出现同样的问题。
ProxyPass的语法与RewriteRule的语法不同。在RewriteRule中,为了引用协议,您应该使用%{SERVER_PROTOCOL}
,如rewrite.html中所解释的那样。
https://stackoverflow.com/questions/17028202
复制相似问题