我希望能够做的是采取以下措施:
http://localhost:10000
http://localhost:11000
http://localhost:12000
并分别路由它们如下:
http://my-app (this is port 10000 traffic)
http://my-app/app (this is port 11000 traffic)
http://my-app/blog (this is port 12000 traffic)
这是我的conf.d文件 -
<VirtualHost *:80>
ServerName my-app.domain.com
ServerAlias my-app
Redirect / https://my-app.domain.com/
</VirtualHost>
<VirtualHost *:443>
ServerName my-app.domain.com
ServerAlias my-app
Include ssl/default/ssl.cfg
RewriteEngine On
ProxyRequests Off
ProxyPreserveHost On
RemoteIPHeader X-Forwarded-For
RequestHeader set X-FORWARDED-SSL on
RequestHeader set X-FORWARDED_PROTO https
ProxyTimeout 900
TimeOut 900
RewriteRule ^$ / [R]
ProxyPass / http://localhost:10000/
ProxyPassReverse / http://localhost:10000/
RewriteRule ^/app/(.*) http://localhost:11000/$1 [P,L]
ProxyPassReverse /app/ http://localhost:11000
</VirtualHost>
重定向正在为初始端口工作,但不适用于流向11000端口的流量。我确定我做的事情很愚蠢,但我不知道是什么。
答案 0 :(得分:5)
您需要指定最具体的&#34;特定的&#34;使用proxypass时首先路径, 指定/ blog / / app / first然后/。如果你不这样做,ProxyPAss /将覆盖其他人。
RewriteRule ^$ / [R]
&lt; - 没有发生,因为在虚拟主机中只有^ / $匹配且^ / $已经/,所以它不起作用,如果它确实会循环。
Aslo,不要使用mod_rewrite,因为不需要代理它,或者至少你没有做任何proxypass或proxypassmatch不能单独做的事情,并且在使用ProxyPass时匹配斜杠(如果有的话)是源添加到目标中的结束斜杠,如果没有,不要,否则可能会发生来自后端的响应的意外行为),并且如前所述,首先指定大多数特定路径:
因此,完全删除mod_rewrite指令并且:
ProxyPass /app/ http://localhost:11000/
ProxyPassReverse /app/ http://localhost:11000/
ProxyPass /blog/ http://localhost:12000/
ProxyPassReverse /blog/ http://localhost:12000/
ProxyPass / http://localhost:10000/
ProxyPassReverse / http://localhost:10000/