apache配置域名转发

     apache配置域名转发,如访问80端口,当域名是a.com时访问tomcat1,当域名是b.com时访问tomcat2。

     在httpd.conf 中加入

      NameVirtualHost *:80
<VirtualHost *:80>
    ServerName hd.jd.net
    ServerAlias hd.jd.net
    ProxyPass / http://localhost:8088/
    ProxyPassReverse / http://localhost:8088/
    ErrorLog logs/man_error.log
    CustomLog logs/man-access_log common
</VirtualHost>

<VirtualHost *:80>
    ServerName huodong.shop.jd.net
    ServerAlias huodong.shop.jd.net
    ProxyPass / http://localhost:8089/
    ProxyPassReverse / http://localhost:8089/
    ErrorLog logs/shop-error_log
    CustomLog logs/shop-access_log common
</VirtualHost>

    然后把LoadModule proxy_module modules/mod_proxy.so 和LoadModule proxy_http_module modules/mod_proxy_http.so的注释放开,重启apache。

    PS:启动时用CMD方式执行httpd.exe,如果用可视化工具的话不太好看错误日志。

猜你喜欢

转载自zy116494718.iteye.com/blog/2287787