Apache的反向代理设置较为简单,按以下步骤进行即可:
1. 下载安装apache http server
2. 安装
3. 编辑apache_install_directory/conf/httpd.conf文件:
1)开启加载反向代理模块,即取消一下两行配置代码的注释:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
2)增加如下配置:
1 <IfModule mod_proxy.c> 2 ProxyRequests off 3 <Proxy *> 4 Order deny,allow 5 Allow from all 6 </Proxy> 7 ProxyPass /rc http://target_host:port/rc 8 ProxyPassReverse /rc http://target_host:port/rc 9 </IfModule> 10将Proxy开启,其中ProxyPass为反向代理主要配置,当请求本机监听的端口,且URL为rc时,Apache将会去目标服务器(destHost)请求,从而代理该请求。ProxyPassReverse配置为Apache 调整HTTP重定向回应中
Location,Content-Location和URI头里的URL。代理的配置详细参数可参见这里。
4. 如果请求量比较大,则考虑关闭apache的访问日志,否则该日志增长过快,且影响性能,在httpd.conf里面注释掉配置项:
#CustomLog "logs/access.log" common
6. 如果是Windows系统,则可能会因为防火墙和杀毒软件的关系,导致apache报以下的异常:
(OS 64)指定的网络名不再可用。 : winnt_accept: Asynchronous AcceptEx failed.
造成该问题的原因是因为Apache使用了Windows的一个封装方法,加入以下配置消除该异常:
Win32DisableAcceptEx
ThreadsPerChild 250
MaxRequestsPerChild 0
7. 如果出现 Server ran out of threads to serve requests. Consider raising the ThreadsPerChild setting 的提示,则考虑增加ThreadsPerChil (子进程的线程数)值。
没有评论:
发表评论