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

时间:2022-10-05 20:44:38

i'm using CentOS release 6.5 (Final) and i installed nginx-1.6.1-1.el6.ngx.x86_64, httpd-2.2.15-31.el6.centos.x86_64 using yum

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

packets flow like below

数据包流如下

external -> nginx:80 -> apache:8080

外部 - > nginx:80 - > apache:8080

when i access server via http://test.zfanta.com always meet 403 error

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

error log

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

nginx setting

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 setting

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>

and /home directory

和/ home目录

/home/: lost+found test zfanta

/ home /:lost + found test zfanta

/home/lost+found:

/home/test: www

/home/test/www: index.html

/home/zfanta: www

/home/zfanta/www: index.php

1 个解决方案

#1


1  

I doubt this

我怀疑这一点

Directory "/home/*/www"

would work (probably it would apply literally to directory /home/*/www, but won't expand). Since / is forbidden by the first Directory, you get that 403. Use something like this instead:

会工作(可能它会直接应用于目录/ home / * / www,但不会扩展)。由于/被第一个目录禁止,你得到403.使用这样的东西代替:

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

#1


1  

I doubt this

我怀疑这一点

Directory "/home/*/www"

would work (probably it would apply literally to directory /home/*/www, but won't expand). Since / is forbidden by the first Directory, you get that 403. Use something like this instead:

会工作(可能它会直接应用于目录/ home / * / www,但不会扩展)。由于/被第一个目录禁止,你得到403.使用这样的东西代替:

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