我正在使用mod_proxy来redirect主要的几个子域的请求到局域网上运行的对应的服务器。 长话短说这里是我的configuration:
ProxyRequests off <VirtualHost 0.0.0.0:80> ServerName sub1.dev.enterprise.com ProxyPass / http://localhost:8888/ ProxyPassReverse / http://localhost:8888/ </VirtualHost> <VirtualHost 0.0.0.0:80> ServerName sub1.dev.enterprise.com ProxyPass / http://sub1.dev.enterprise.com:8080/ ProxyPassReverse / http://sub1.dev.enterprise.com:8080/ </VirtualHost>
在Apache重新启动任何请求.dev.enterprise.com /结束在http:// localhost:8888 /为什么这样?
在两个configuration节中都有相同的ServerName。
尝试运行“apache2ctl -t”(debian语法,但其他发行版应该有一个类似的命令)来testing你的configuration。 Apache也会在日志文件中告诉你这些明显的错误。
顺便说一下:使用VirtualHost时不要忘记设置NameVirtualHost。