centos下apache反向代理设置

来源:互联网 发布:淘宝卖家怎么提升等级 编辑:程序博客网 时间:2024/05/22 03:43

今天公司想要做一个微信公共平台,做这个东西的开发人员不会用php,就在服务器上自己搭了一个tomcat。问题出来了:服务器80端口我已经用掉了,他的tomcat只能用其他端口(用的8080),而微信公共平台只支持80端口。。。


于是折腾了半天,通过apache反向代理的方式,将请求微信公共平台的请求导向8080端口。

由于当时apache当时安装时没有加载proxy模块,所以我去官网下载了这个模块的源码:http://apache.webthing.com/mod_proxy_html/  官网说这个模块安装还需要mod_xml2enc,其实在这个网页中下载的源码已经包含了mod_xml2enc。


下载到服务器上,解压之后,直接运行

apxs -c -I/usr/include/libxml2 -I. -i mod_proxy_html.capxs -c -I/usr/include/libxml2 -I. -i mod_xml2enc.c
proxy模块就自动安装好了,然后配置虚拟主机文件:/usr/local/apache2/conf/extra/httpd-vhosts.conf
<virtualhost xx.xx.xx.xx:80>        ServerAdmin admin@padandroid.com        DocumentRoot "/var/www/html/xxx"        ServerName www.yourdomain.com        ErrorLog "/var/www/html/xxx/logs/error_log"        CustomLog "/var/www/html/xxx/logs/access_log" common        <Directory "/var/www/html/xxx">                Options Indexes FollowSymLinks                AllowOverride All                Order allow,deny                Allow from all        </Directory>        ProxyPreserveHost On        ProxyRequests Off        ProxyPass /wechat http://www.yourdomain:8080/wechat/        ProxyPassReverse /wechat http://www.yourdomain.com:8080/wechat/</virtualhost>
重启apache服务:service httpd restart
OK,再次访问http://www.yourdomain.com/wechat 成功转向 http://www.yourdomain.com:8080/wechat
这个配置 也可以导向不同的服务器地址,有用!

0 0