Nginx 下有很多網域網站 當網域名稱解析到伺服器上的 時候 造訪時 報錯了 403 或404
因為伺服器還沒有配置 域名, 在直接存取伺服器的ip 時 也是報錯的
404 Not Found
nginx/1.4.4
或
403 Not Found
nginx/1.4.4
這樣的錯誤 我想修改一下 這樣報錯訊息!對 是 網域解析到伺服器了 而伺服器 沒有做該網域的設定; 報了403錯誤 或 存取伺服器 ip 位址
nginx.conf 如下 該怎麼配置自訂的 403 和 404 呢
user www www;
worker_processes 1;
error_log /alidata/log/nginx/error.log crit;
pid /alidata/server/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
events
{
use epoll;
worker_connections 65535;
}
http {
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
log_format '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
include /alidata/server/nginx/conf/vhosts/*.conf;
}
PHPz2017-05-16 17:25:16
http://nginx.org/en/docs/http/ngx_http_core_module.html#error_page
自訂404頁,例如交給PHP處理:
error_page 404 = /404.php;
403類似.