0

ベアネットインストールマシン+ nginx + php-fpmを備えたテストVirtualbox / Debian Wheezy7.1マシンをセットアップしました

SSL、php、basic_auth、および許可/拒否をサーバーレベルで使用しています。

ただし、認証を 1 つのパスのみにしたい場合、認証は機能しますが、PHP は機能しません (index.php は Web ブラウザーにダウンロードされます)。

nginx がロケーション ディレクティブをどのように一致させるかに関係があることは知っていますが、それが何であるかはわかりません...

ここに私の設定ファイルがあります:

server {
       listen         80;
       server_name    www.test.com;
       rewrite        ^ https://$server_name$request_uri? permanent;
}



# HTTPS server

server
{
    listen 443;
    server_name www.test.com;

    root /srv/vhosts/www.test.com/html;
    index index.php ;

    ssl on;
    ssl_certificate /etc/nginx/certs/STAR.test.com.crt;
    ssl_certificate_key /etc/nginx/certs/STAR.test.com.key;

    ssl_session_timeout 5m;

    ssl_protocols SSLv3 TLSv1;
    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
    ssl_prefer_server_ciphers on;


    location / {
        try_files $uri $uri/ =404;
    }
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini

                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        location ~ /\.ht {
                deny all;
        }   

    location ^~ /testdir/ {
        auth_basic "gib login";
        auth_basic_user_file /etc/nginx/htpasswd/www.test.com.htpasswd;
        allow 192.168.1.3;   # my workstation ip
        deny all;
    }
}

編集:最初のコメントを見てください、ありがとう!

4

1 に答える 1