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;

   #keepalive_timeout  0;
   keepalive_timeout  65;

   #gzip  on;

   # fastcgi_intercept_errors on | off;
   # 启用自定义错误页面
   fastcgi_intercept_errors on;

   server {
       listen       80;
       server_name  localhost;

       charset utf8;

       access_log  logs/80-access.log  main;
       error_log  logs/80-error.log error;

       location / {
           root   html;
           index  index.html index.htm;
       }

       # 使用腾讯公益404页面
       error_page  404              /404.html;
       location = /404.html {
           root   html;
       }

       # error_page 404 = http://www.test.com/error.html;

       # redirect server error pages to the static page /50x.html
       #
       error_page   500 502 503 504  /50x.html;
       location = /50x.html {
           root   html;
       }
}

注:404.html和50x.html都在html文件夹下,显示404页面无效

  • 饭团🍙    2019-12-12 10:15:02
  • 阅读 1606    收藏 0    回答 1
  • 邀请
  • 收藏
  • 分享
发送
登录 后发表评论
  • 51testing软件测试圈微信