我按如下所示设置Apache反向代理:
<VirtualHost *:80>
ServerName aa.domain1.com
ServerAlias aa.domain1.com
Header always set X-Frame-Options SAMEORIGIN
ProxyPass "/Apache24_Status.txt" "!"
ProxyPass / http://aa.domain2.com/
ProxyPassReverse / http://aa.domain2.com/
ProxyPassReverseCookiePath / /
</VirtualHost>
<VirtualHost *:80>
ServerName bb.domain1.com
ServerAlias bb.domain1.com
Header always set X-Frame-Options SAMEORIGIN
ProxyPass "/Apache24_Status.txt" "!"
ProxyPass / http://bb.domain2.com/
ProxyPassReverse / http://bb.domain2.com/
ProxyPassReverseCookiePath / /
</VirtualHost>
它工作正常,但是我们有很多子域;然后我们必须为每个虚拟主机添加virtualhost。是否可以像这样设置virtualhost:
<VirtualHost *:80>
ServerName domain1.com
ServerAlias *.domain1.com
Header always set X-Frame-Options SAMEORIGIN
ProxyTimeout 3600
ProxyPass "/Apache24_Status.txt" "!"
ProxyPass / http://*.domain2.com/
ProxyPassReverse / http://*.domain2.com/
ProxyPassReverseCookiePath / /
</VirtualHost>
然后它将将domain1.com的所有子域都反转为domain2.com。