Apache2服务器反代理配置

https://www.jianshu.com/p/15538d9f7a67

前言:对于反代理这个词呢,总会想到nginx服务器,然而今天想让apache与nginx在同一个端口跑,不知道是我玩挂了还是nginx不稳定,时而正常时而~~,由于weblogic在多model的情况下url总是带有war_exploded的,然而我就尝试用apache2反代理到内网weblogic服务器。


****Step-One:使用a2enmod命令加载proxy模块****

sudo a2enmod proxy proxy_balancer proxy_http

****Step-Two:修改主机站点配置文件****
path:/etc/apache2/sites-enabled/000-default.conf

<VirtualHost *:80>
        #自定义域名
        ServerName example.com
        #off表示开启反向代理,on表示开启正向代理
        ProxyRequests Off
        ProxyMaxForwards 100
        ProxyPreserveHost On
        #反代理要解析的ip 支持添加端口 
        ProxyPass / http://172.16.168.35:7001/
        ProxyPassReverse / http://172.16.168.35:7001/

        <Proxy *>
            Order Deny,Allow
            Allow from all
        </Proxy>
</VirtualHost>

****价值源于技术,贡献源于分享****
Nginx服务器反代理配置
Apache2反代理配置



一个实例
原先在服务器上部署了wordpress,使用了80,443端口访问。内部使用apache2,访问域名为https://www.cloudfuturo.com/。使用了https强制跳转
然后又部署了一个discuz服务,使用了8080端口外部访问,配置了域名http://forum.cloudfuturo.com/
 
www.cloudfuturo.com和forum.cloudfuturo.com是相同的外网地址,现在想直接使用forum.cloudfuturo.com访问discuz服务,不加端口号
 
需要修改配置文件000-default.conf
<VirtualHost *:80>
        ServerName cloudfuturo.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        RewriteEngine   on
       # RewriteCond %{HTTPS} !=on
       # RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [L,R=301]

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>



<VirtualHost *:80>
        ServerName forum.cloudfuturo.com
        ProxyPreserveHost On
        ProxyRequests Off
        ProxyPass / http://forum.cloudfuturo.com:8080/
        ProxyPassReverse / http://forum.cloudfuturo.com:8080/

        <Proxy *>
            Order Deny,Allow
            Allow from all
        </Proxy>
       # RewriteEngine   on
       # RewriteCond %{HTTPS} !=on
       # RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [L,R=301]
</VirtualHost>

 

cloudfuturo.com中的强制跳转需要注释掉,否则访问discuz会直接跳到wordpress.
forum.cloudfuturo.com还没有配置https,后面配置不知道会不会有问题
 
 
posted @ 2021-07-28 12:05  坚强的小蚂蚁  阅读(446)  评论(0编辑  收藏  举报