CentOS 7下Apache反向代理

最近用到反向代理,本来nginx超简单设置,公司服务器却只有apache,不太会弄,无赖,查文档呗。


ProxyRequests Off


Order deny,allow
Allow from all


ProxyPass / http://192.168.1.19:8080/
ProxyPassReverse / http://127.0.0.1:8080/

但是无论怎么配置,总是返回503,

apache日志返回错误:

[Mon Mar 07 13:35:34.761858 2016] [proxy:error] [pid 29084] (111)Connection refused: AH00957: HTTP: attempt to connect to 192.168.1.19:8080 (192.168.1.19) failed
[Mon Mar 07 13:35:34.761953 2016] [proxy:error] [pid 29084] AH00959: ap_proxy_connect_backend disabling worker for (192.168.1.19) for 60s
[Mon Mar 07 13:35:34.761966 2016] [proxy_http:error] [pid 29084] [client 192.168.1.150:24787] AH01114: HTTP: failed to make connection to backend: 192.168.1.19

网上找了好多类似的状况,说是因为Selinux阻止了,但是查看了selinux运行状态,selinux=disabled,所以问题肯定不在这,然后继续coding...

下午突然想到,我的代码审查gerrit不就是反代么,所以,比对文件,修改配置:


    ProxyRequests Off
    ProxyVia Off
    ProxyPreserveHost On

    
          Order deny,allow
          Allow from all
    

ProxyPass / http://192.168.1.19:8080/
ProxyPassReverse / http://127.0.0.1:8080/

重启apache

好吧,一切运行了~~



6 评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注