403簡単なテストページにアクセスしようとすると禁止


13

nginxをインストールしたばかりで、最初のサイトをセットアップしようとしています。php-fpmでnginxを使用しようとしています。nginxがインストールされています(IPにアクセスすると、デフォルトのWelcome to 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.phpの所有者はnginxです(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;
    }
}

回答:


22

あなたの設定は意図的にそれをブロックしています:

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

これは、スラッシュの後に任意の種類の文字が続く要求に一致します。.正規表現の文字は、「任意の文字」を意味します。

私はあなたがリテラルをチェックするつもりだったと仮定しています.; それはこの設定になります:

location ~ /\. {

そうでない場合はお知らせください!


OMG私は今、とても愚かだと感じています(私がこれを主演しているという事実を考慮して、うーん、「しばらく」)。あなたの迅速な対応に感謝!
user6669
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.