nginx conf 配置默认错误提示页友好提示页面界面 NGINX
配置NGINX.conf文件 在首个域名配置地方 配置 屏蔽域名响应服务器,指定到不存在的服务,
响应时间调整为1秒 提高响应速度
代码配置 以下黄色标识位, 我们需要在 nginx的安装目录下 root / html 下 , 放入相应的 错误提示界面即可。
#user nginxu nginxg;
worker_processes 4;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid logs/nginx.pid;
events {
worker_connections 10240;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#del versioninfo
server_tokens off;
#keepalive_timeout 0;
keepalive_timeout 75s 120s; #two min
#gzip 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 text/javascript image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
#ping bi yu ming
upstream pingbi.xxx.cn {
server 10.192.2.15:8090; //局域网IP 端口
}
server{
listen 80;
server_name pingbi.xxx.cn;
#larger the keep alive time for client
large_client_header_buffers 4 16k;
client_max_body_size 300m;
client_body_buffer_size 128k;
proxy_connect_timeout 1s; #one min
proxy_read_timeout 120s;
proxy_send_timeout 120s;
proxy_buffer_size 64k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
#reject iframe refer within other domains
add_header X-Frame-Options "SAMEORIGIN";
#add error tip
proxy_intercept_errors on;
error_page 403 404 500 502 503 504 /50x.html;
location = /50x.html{
root html;
}
location / {
proxy_pass http://pingbi.xxx.cn;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
###主服务器监控80入口的所有请求
server {
listen 80;
server_name localhost;
#reject iframe refer within other domains IFRAME 引用配置
add_header X-Frame-Options "SAMEORIGIN";
#charset koi8-r;
access_log logs/host.access.log main;
location / {
root html;
index elleage.html elleage.htm;
}
error_page 404 404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
location ~ /\.ht {
deny all;
}
}
}
至此 屏蔽友好提示配置完成, 此配置 可以在NGINX模块 直接 屏蔽尚未配置的域名
如有疑问 请留言 欢迎提供建议
评论已有 0 条