linux

ubuntu下apache+tomcat基于ajp协议的反代配置

发布时间:9年前热度: 3724 ℃评论数:

ubuntu下apache+tomcat基于ajp协议的反代配置 

环境是UBUNTU 最新版apache2安装的目录结构有变化网上很多文章都不适用了。 

准备 

如果你原程序有问题,先清理一下 

  1. apt-get --purge remove apache2  
  2. apt-get --purge remove apache2.2-common  
  3. apt-get autoremove  
  4. apt-get --purge remove apache-common  
  5. apt-get --purge remove apache  
  6. sudo find /etc -name "*apache*" -exec rm -rf {} /;  
  7. sudo rm -rf /var/www  
  8. dpkg -l |grep apache2|awk '{print $2}'|xargs dpkg -P #删除关联

安装 

  1. apt-get install apache2  
  2. service apache2 stop  


配置 
(1) 

  1. a2enmod proxy proxy_ajp proxy_balancer proxy_connect proxy_ftp proxy_http  

(2) 
修改配置 sudo vim /etc/apache2/mods-enabled/proxy.conf 

如果有内容设置则设置如下: 

  1. <IfModule mod_proxy.c>  
  2.    #turning ProxyRequests on and allowing proxying from all may allow  
  3.    #spammers to use your proxy to send email.  
  4. ProxyRequests Off  
  5. <Proxy *>  
  6. Require all granted
  7. </Proxy>  

(3) 
修改配置vim /etc/apache2/sites-enabled/000-default.conf 

  1. <VirtualHost *:80>  
  2.         ServerName www.zhl123.cn  
  3.         ServerAdmin [email protected]
  4.         ProxyPass / ajp://127.0.0.1:8009/  
  5.         ProxyPassReverse / ajp://127.0.0.1:8009/  
  6. </VirtualHost>


(4)安全相关的版本号隐藏 
修改配置 vim /etc/apache2/conf-enabled/security.conf 
ServerSignature Off 
ServerTokens Prod 

17.png


重启服务测试一下吧,你现在已经可以使用ajp代理至后端了

apache,基于,协议,配置

手机扫码访问