我有一个带有单个IP的VP。VPS应为3个网站提供服务。site1 -www.domain.com通过WordPress。site2 -sub.domain.com通过WordPress。site3- anothersub.domain.com通过docker容器内部的nodejs,该容器在端口81上听。Site1和site2非常简单,只需设置虚拟主机即可。但是,如何为site3设置apache?您能提供一个示例或正确的语法吗?
来自apache docs(https://httpd.apache.org/docs/current/vhosts/examples.html#proxy)
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass "/" "http://192.168.111.2/"
ProxyPassReverse "/" "http://192.168.111.2/"
ServerName hostname.example.com
</VirtualHost>
,对于您的情况:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/" "http://localhost:81/"
ProxyPassReverse "/" "http://localhost:81/"
ServerName hostname.example.com
</VirtualHost>
祝你好运!