403 간단한 테스트 페이지에 접근하려고 할 때 금지 “example.com” 파일은 /srv/www/test/index.phpnginx가

방금 nginx를 설치했으며 첫 번째 사이트를 설정하려고합니다. php-fpm과 함께 nginx를 사용하려고합니다. nginx가 설치되었습니다 (내 IP로 이동하면 기본적으로 nginx 페이지에 오신 것을 환영합니다).

이제 간단한 스크립트를 실행하려고합니다.

<?php
phpinfo();

그러나 나는 403 Forbidden 페이지를 계속 누르고 있습니다. 내 가상 호스트의 로그에서 다음과 같은 많은 줄을 볼 수 있습니다.

2012/05/18 01:29:45 [error] 4272#0: *1 access forbidden by rule, client: x.170.147.49, server: example.com, request: "GET / HTTP/1.1", host: "example.com"

파일은 /srv/www/test/index.phpnginx가 소유자입니다 ( 777파일을 포함하여 전체 경로를 사용할 수는 없었습니다).

nginx가 실제로 nginx/nginx구성의 사용자 및 그룹 에서 실행되고 있는지 확인 했습니다. nginx.conf에서 다른 설정이 방해받지 않도록 기본 설정 포함 경로를 변경했습니다 ( include /etc/nginx/sites-enabled/).

내가 사용하는 구성은 다음과 같습니다 (다른 구성이 필요한 경우 (php-fpm / nginx.conf) 알려주십시오).

server {
    listen 80;

    server_name example.com;
    root /srv/www/test;
    access_log /var/log/nginx/example-access.log;
    error_log  /var/log/nginx/example-error.log error;

    location ~ /.          { access_log off; log_not_found off; deny all; }
    location ~ ~$           { access_log off; log_not_found off; deny all; }

    location ~* .(js|css|png|jpg|jpeg|gif|ico|xml|swf|flv|eot|ttf|woff|pdf|xls|htc)$ {
        add_header Pragma "public";
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
        log_not_found off;
        expires   360d;
    }

    location ~ /.ht {
        deny all;
        access_log off;
        log_not_found off;
    }

    location ~ /. {
        access_log off;
        log_not_found off;
        deny all;
    }

    location ~ ^/(index|frontend_dev|admin|staging).php($|/) {
        #rewrite ^/(.*)/$ /$1 permanent;
        fastcgi_split_path_info ^(.+.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;

    }

    location / {
        index index.php;
        try_files $uri /index.php?$args;
    }
}



답변

구성이 의도적으로 구성을 차단하고 있습니다.

location ~ /. {
    access_log off;
    log_not_found off;
    deny all;
}

그것은 슬래시 다음에 어떤 종류의 문자가 오는 모든 요청과 일치합니다. .정규 표현식 의 문자는 “모든 문자”를 의미합니다.

나는 당신이 리터럴을 확인하려고한다고 가정합니다 .. 그것은이 구성 일 것입니다 :

location ~ /\. {

그렇지 않은 경우 알려주세요!


답변