我想设置一个Apache服务器,以便它将请求https://example.edu/rdemos/(.*)
重定向到运行在端口3838上的闪亮服务器。其他网页应转到正常的代理服务器。
所以我在ssl.conf
中有以下指令:
RewriteEngine on
RewriteRule ^/PP/(.*) https://example.com/PhysicsPlayground/$1
<Location /rdemos>
RedirectMatch permanent ^/rdemos$ /rdemos/
RewriteEngine on
RewriteCond %{HTTP:Upgrade} =websocket
RewriteRule /rdemos/(.*) ws://localhost:3838/$1 [P,L]
RewriteCond %{HTTP:Upgrade} !=websocket
RewriteRule /rdemos/(.*) http://localhost:3838/$1 [P,L]
ProxyPass http://localhost:3838/
ProxyPassReverse http://localhost:3838/
# Header edit Location ^/ /rdemos/
</Location>
这会正确地重定向/rdemos
下的文件,因此https://example.com/rdemos/index.html
会像预期的那样转到shiny服务器(端口3838)。
但是,其他文件会被随机重定向。所以https://example.com/PP/demo.html
被路由到https://example.com/rdemos/PhysicsPlayground/demo.html
(它不存在)。
我做错了什么?
我使用Apache/2.4.37(Red Hat Enterprise Linux)OpenSSL/1.1.1k mod_fcgid/2.3.9 SVN/1.10.2 mod_wsgi/4.6.4 Python/3.6 mod_apreq2-20101207/2.8.1
1条答案
按热度按时间nwnhqdif1#
我不会尝试混合使用mod_alias和mod_rewrite指令。把所有东西都转换成mod_rewrite,因为你需要使用它。
重定向重写规则应该使用
[R=301,L]
我不会尝试将
ProxyPass
与带有P
标志的重写规则混合在一起。使用重写规则。在重写规则时使用
^/?
具有更好的可移植性,因此它们可以在.htaccess
中工作而无需修改。您永远不需要多次指定
RewriteEngine on
。ProxyPassReverse
应指定该值。