我有一个运行 apache2 的服务器,它有一些位于/var/www/html
的应用程序例:
www.server.com/app
www.server.com/app2
在同一台服务器中,我让 Docker 在端口 9090 上运行应用程序
我想在 url www.server.com/app3 处输入浏览器,请求将被重定向到端口 9090
我在可用的网站上尝试了此设置,但不起作用:
<VirtualHost *:80>
ServerName server.com/app3
ServerAlias /app3
ProxyPreserveHost On
ProxyPass /app3 http://server.com:8080/
ProxyPassReverse /app3 http://server.com:8080/
</VirtualHost>
你可以在 apache config 中使用 location
NameVirtualHost *:80
NameVirtualHost *:443
<VirtualHost *:80>
ServerName abrfanet.com
ServerAlias www.abrfanet.com
ServerAdmin xxx@gmail.com
ProxyPass / http://container_name:PORT/
ProxyPassReverse / http://container_name:PORT/
ProxyPass /public !
ProxyRequests Off
ProxyPreserveHost On
RewriteEngine On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<Location />
ProxyPass http://container_name:PORT/
ProxyPassReverse http://container_name:PORT/
SetEnv proxy-sendchunks 1
</Location>
<Location /app2/>
ProxyPass http://container_name2:PORT2/
ProxyPassReverse http://container_name2:PORT2/
SetEnv proxy-sendchunks 1
</Location>
<Location /app3/>
ProxyPass http://container_name3:PORT3/
ProxyPassReverse http://container_name3:PORT3/
SetEnv proxy-sendchunks 1
</Location>
</VirtualHost>
我也建议你,你可以在Docker中使用Apache
它更容易工作