我对Nginx不太满意,所以我非常感谢这里的一些帮助。
现在我的问题是,我的默认服务器阻止domain.com,拒绝访问所有php
个文件。
在www.domain.com/index.php
我显示正确的403 Forbidden页面。
但如果我前往www.SomeRandomSubDomain.domain.com/index.php
,我可以看到文件就好了。
我没有任何其他服务器块。我在下面的第一行中错过了某种标记吗?
location ~ \.php$ {
deny all;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in
# php.ini
# With php5-cgi alone: fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#include fastcgi_params;
include fastcgi.conf;
}
如果您需要任何其他信息以便进一步帮助我,请告诉我,这让我陷入了混乱的世界,我对Google没有幸运。
以下是完整文件:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name EXAMPLE.com www.EXAMPLE.com;
root /var/www/html;
index index.html index.php index.htm;
location / {
try_files $uri $uri/ $uri.html $uri.php?$query_string;
# Uncomment to enable naxsi on this location include
# /etc/nginx/naxsi.rules
}
location ~ .(css|img)/(.+)$ {
try_files $uri $uri/ /$1/$2;
}
error_page 404 403 /404.php;
location ~ \.php$ {
deny all;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in
# php.ini
# With php5-cgi alone: fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#include fastcgi_params;
include fastcgi.conf;
}
}
答案 0 :(得分:1)
尝试从php配置中删除deny all;