我已经建立了一个测试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