Need help setting up: Apache Reverse Proxy

允我心安 提交于 2019-11-27 18:43:57

问题


I have some trouble setting my virtualhosts file up the right way. I'd like to send vistors to the right server by using reverse proxy. My current setup gives me an internal error.

i have only 1 public ip and want to proxy the visitor on the condition of the right servername to one of the local virtual servers.

NameVirtualHost *:80

<VirtualHost *:80>
    ServerName sub.domain.com
    ServerAdmin me@domain.com
    ProxyPreserveHost On
    ProxyPass / http://192.168.1.11:80
    ProxyPassReverse / http://192.168.1.11:80
</VirtualHost>

<VirtualHost *:80>
    ServerName otherdomain.com
    ServerAdmin me@domain.com
    ProxyPreserveHost On
    ProxyPass / http://192.168.1.12:80
    ProxyPassReverse / http://192.168.1.12:80
</VirtualHost>

If someone can find anything I'm doing wrong or has another way to achieve my goal i'd love to hear so..


回答1:


Got it working! used the following setup:

<VirtualHost *:80>
    ServerName sub.domain.com
    ServerAdmin me@domain.com

    ProxyRequests Off

    ProxyPreserveHost On

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass / http://192.168.1.11/websvn/
    ProxyPassReverse / http://192.168.1.11/websvn/
</VirtualHost>

the /websvn/ part was neccesary to include the css and other files properly

In another loaded .conf file:

 LoadModule proxy_connect_module /usr/lib/apache2/modules/mod_proxy_connect.so
 LoadModule proxy_ftp_module /usr/lib/apache2/modules/mod_proxy_ftp.so
 LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

Which is used to inlcude the neccesary modules



来源:https://stackoverflow.com/questions/8282587/need-help-setting-up-apache-reverse-proxy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!