Apache配置反向代理到tomcat

2018年4月24日11:11:45
  • Apache配置反向代理到tomcat已关闭评论
  • 148 views
  • A+
所属分类:CentOS 网站建设

1、使用find / -name httpd-vhosts.conf

 

默认在/usr/share/doc/httpd-2.4.6/httpd-vhosts.conf

 

1找到 httpd-vhosts.conf 的路径 进行配置

在末尾添加:

<VirtualHost *:80>

ServerAdmin test@test.com

ServerName www.test.com

ProxyRequests Off

<Proxy *>

Order deny,allow

Allow from all

</Proxy>

ProxyPass /examples http://192.168.1.250:8080/examples

ProxyPassReverse /examples http://192.168.1.250:8080/examples

</VirtualHost>

 

或者

 

<VirtualHost *:80>

ServerAdmin test@haozjz.com

ServerName www.haozjz.com

ProxyRequests Off

<Proxy balancer://myset>

BalancerMember http://116.196.85.138:8080/shopping/

BalancerMember http://116.196.85.138:8080/shopping/admin loadfactor=3 timeout=1

ProxySet lbmethod=byrequests

</Proxy>

<Proxy balancer://myset2>

BalancerMember http://116.196.85.138:8080/employee-ssm/

BalancerMember http://116.196.85.138:8080/employee-ssm loadfactor=3 timeout=1

ProxySet lbmethod=byrequests

</Proxy>

 

ProxyPass /shopping "balancer://myset"

ProxyPassReverse /shopping "balancer://myset"

ProxyPass /employee-ssm "balancer://myset2"

ProxyPassReverse /employee-ssm "balancer://myset2"

</VirtualHost>

配置多个代理,加入负载均衡

 

2、找到 httpd.conf

默认在/etc/httpd/conf/httpd.conf

 

 

增加如下配置

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

LoadModule proxy_http_module modules/mod_proxy_http.so

 

Include /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf (注意配置文件路径)

 

参考:

https://www.cnblogs.com/-brl/p/7463875.html

https://www.linuxidc.com/Linux/2017-10/147534.htm

https://www.cnblogs.com/f1194361820/p/5110956.html

 

 

 

 

avatar