我已經建立了一個測試VirtualBox的/ Debian的Wheezy7.1機裸淨安裝機+ nginx的+ PHP-FPMPHP不是一個位置指令
我有SSL,PHP,basic_auth內工作並允許/拒絕在服務器級別上工作。
但是,如果我想在auth東西是隻有一條路徑中,auth的作品,但PHP的東西不(在index.php獲取網頁瀏覽器下載)
我知道它有什麼做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;
}
}
編輯:看的第一個評論,謝謝!
我設法解決了我的問題,將'location ^〜/ testdir /'更改爲'location/testdir /'。我仍然不知道這是爲什麼會起作用,並希望有人能詳細說明。謝謝! – Kaurin