简体   繁体   English

需要设置帮助:Apache反向代理

[英]Need help setting up: Apache Reverse Proxy

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. 我只有1个公共ip,并希望在正确的服务器名的情况下将访问者代理到本地虚拟服务器之一。

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.. 如果有人可以找到我做错的事情,或者有另一种方式可以实现我的目标,我很乐意听到。

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 / websvn /部分必须正确包含css和其他文件

In another loaded .conf file: 在另一个已加载的.conf文件中:

 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 用来包含必要的模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM