我有两个网站在 apache 中部署在两个端口 81 和 82
<VirtualHost *:81>
DocumentRoot "D:/WebApps/App1"
ServerName localhost
<Directory "D:/WebApps/App1">
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:82>
DocumentRoot "D:/WebApps/App2"
ServerName localhost
<Directory "D:/WebApps/App2">
Require all granted
</Directory>
</VirtualHost>
我已经进行了如下两个 DNS 条目
app1.domain.com <server ip>
app2.domain.com <server ip>
我想在端口上配置反向代理80
,以便使用 发出的请求app1.domain.com
被代理到端口81
,使用 发出的请求app2.domain.com
被代理到端口82
到目前为止我已经尝试过 -
<VirtualHost app1.domain.com:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName app1.domain.com
ServerAlias app2.domain.com
ProxyPass / http://localhost:81/
ProxyPassReverse / http://localhost:81/
</VirtualHost>
<VirtualHost app2.domain.com:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName app1.domain.com
ServerAlias app2.domain.com
ProxyPass / http://localhost:82/
ProxyPassReverse / http://localhost:82/
</VirtualHost>
但是两个域的请求都被发送到端口 81。有人能提出解决方案吗?