日期:2014-05-17  浏览次数:21021 次

apache2 反向代理设置 no permission问题

环境ubuntu+apache2

在apache2配置文件default中设置了反向代理:

?

    <Proxy http://xxx.com/http-bind>
         Order allow,deny
         Allow from all
    </Proxy>
    ProxyPass /go http://xxx.com/http-bind
    ProxyPassReverse /go http://xxx.com/http-bind

?

然后访问 http://mysite.com/go,显示:

error403

You don't have permission to access /http-bind on this server.

google了半天,各种说法都有,最后问题解决了.

?

问题所在:

sudo vim /etc/apache2/mods-enabled/proxy.conf

<IfModule mod_proxy.c>
        #turning ProxyRequests on and allowing proxying from all may allow
        #spammers to use your proxy to send email.

        ProxyRequests Off

        <Proxy *>
                AddDefaultCharset off
                Order deny,allow
                Deny from all
                #Allow from .example.com
        </Proxy>

        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block

        ProxyVia On
</IfModule>
?

看红色部分,这就是代理不能被访问的原因所在.


??????? <Proxy *>
??????????????? AddDefaultCharset off
??????????????? Order deny,allow
??????????????? Deny from all
??????????????? #Allow from .example.com
??????? </Proxy>

?

?

只要将红色部分注释了,或者将#Allow from .example.com的注释取消,换上你的domain即可.

?

?

?

总结:apache要是有问题,,先去看看它的日志,这个是很有用的.

?

?

?

?

?

?