告诉我我是否要在这里生气...
我在Nginx 1.10.3上有一个基本的PHP 5.6网站
由于某种原因,它不会将404记录到nginx.conf中声明的/var/log/nginx/error.log文件中。 PHP错误最终就可以了,但是404错误就没有。
这是服务器配置:
server {
listen 443;
server_name staging.domain.co.uk;
root /var/www/domain.co.uk;
index index.php;
ssl on;
ssl_certificate /etc/ssl/certs/staging.domain.co.uk.crt;
ssl_certificate_key /etc/ssl/private/staging.domain.co.uk.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
location / {
try_files $uri $uri/ @extensionless-php;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
}
error_page 404 /pnf.php;
}
另外,nginx.conf是...
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
有人可以告诉我我是否要生气吗?我只想知道为什么它根本不列出404 !!
TIA!
答案 0 :(得分:0)
因为该指令:
error_page 404 /pnf.php;
使Nginx将404重定向到该URL,并向客户端返回302响应代码。