我想使用虚拟主机将我的流量从我的子域名(即 blog.somesite.com)重定向到端口(即 somesite.com:3000)。我的默认虚拟主机配置是:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/somesite.com/httpdocs/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
我做的改变:
<VirtualHost somesite.com:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/somesite.com/httpdocs/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost blog.somesite.com:80>
ServerName blog.somesite.com
ServerAlias www.blog.somesite.com
ProxyPass / http://somesite.com:3000/
ProxyPassReverse / http://somesite.com:3000/
</VirtualHost>
这样我的网站就瘫痪了。我做错了什么?
答案1
您无法在“VirtualHost”中输入 DNS 名称。请尝试以下操作:
<VirtualHost *:80>
ServerName somesite.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/somesite.com/httpdocs/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName blog.somesite.com
ServerAlias www.blog.somesite.com
ProxyPass / http://somesite.com:3000/
ProxyPassReverse / http://somesite.com:3000/
</VirtualHost>