Apache配置反向代理

背景:某个公网IP的80端口已经映射,需要配置apache虚拟主机来做反向代理某个应用的服务。

打开Apache安装目录 conf 文件夹下httpd.conf
1、将以下两行前的注释字符 # 去掉:

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

2、在httpd-vhosts.conf文件最后加上转发规则
eg:

    ProxyPass /laa http://56.16.30.63:8080/laa
    ProxyPassReverse /laa http://56.16.30.63:8080/laa

将/laa开头的请求转发到206服务器8080端口的laa上

依次类推,其他的转发也是通过这种方式设置
ProxyPass /aip http://56.16.30.63:9090/aip
ProxyPassReverse /aip http://56.16.30.63:9090/aip

完整配置如下:

<VirtualHost *:80>
    ServerName www.xxx.cn
    DirectoryIndex  index.html
    DocumentRoot "/fs01/ppstore"
    ProxyRequests off
    ProxyPass /laa http://56.16.30.63:8080/laa
    ProxyPassReverse /laa http://56.16.30.63:8080/laa
    <Directory "/fs01/ppstore">
        AllowOverride All
        Options Indexes FollowSymLinks MultiViews
        Require all granted
    </Directory>
        <Location /application/>
        Order allow,deny
        Deny from all
        </Location>
    ErrorLog "/etc/httpd/logs/www.xxx.cn-error_log"
    CustomLog "/etc/httpd/logs/www.xxx.cn-access_log" combined
</VirtualHost>

重启httpd

访问http://IP/laa 就相当于访问配置中http://56.16.30.63:8080/laa

备注:在于AIP结合子系统配置的路径不能写全路径比如:http://56.16.30.63/aip,要填成/aip;写全路径浏览器会直接去访问设置的地址,不会在通过apache的转发。其他的相关配置项也需做相应调整。

猜你喜欢

转载自www.cnblogs.com/Dev0ps/p/10062783.html
今日推荐