apache错误 - 通过nginx反向代理在虚拟主机上禁止403

时间:2014-08-20 19:42:52

标签: linux apache nginx

我正在使用CentOS 6.5版(最终版),我使用yum安装了nginx-1.6.1-1.el6.ngx.x86_64,httpd-2.2.15-31.el6.centos.x86_64

数据包流如下

外部 - > nginx:80 - >阿帕奇:8080

当我通过http://test.zfanta.com访问服务器时总是遇到403错误

错误日志

[Thu Aug 21 03:34:06 2014] [error] [client 211.49.54.233] (13)Permission denied: access to / denied

nginx设置

server {
    listen       80;
    server_name  test.zfanta.com;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location / {
        proxy_pass   http://127.0.0.1:8080;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X_FORWARDED_PROTO http;
        proxy_set_header X-Url-Scheme $scheme;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

apache设置

Listen 8080

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
</Directory>

<Directory "/home/*/www">
    AllowOverride FileInfo
    Options FollowSymLinks Indexes
    Order allow,deny
    Allow from all
</Directory>

NameVirtualHost *:8080

<VirtualHost *:8080>
    DocumentRoot /home/zfanta/www
    ServerName test.zfanta.com
    ErrorLog logs/test.zfanta.com-error
    CustomLog logs/test.zfanta.com
</VirtualHost>

和/ home目录

/家/: 丢失+找到测试zfanta

/家庭/丢失+实测值:

/家/测试: WWW

/家/测试/ WWW: 的index.html

/家/ zfanta: WWW

/家庭/ zfanta / WWW: 的index.php

1 个答案:

答案 0 :(得分:1)

我怀疑这个

Directory "/home/*/www"

可行(可能会将字面应用于目录/home/*/www,但不会扩展)。由于第一个/禁止Directory,因此您可以获得403.请使用以下内容:

Directory ~ "/home/[^/]+/www"