自定义Nginx返回页面

Posted littlevigra

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自定义Nginx返回页面相关的知识,希望对你有一定的参考价值。

1.403返回页面

#user  nobody;
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  65500;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
#    fastcgi_intercept_errors on;
    #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;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_comp_level 2;
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary off;
upstream app {
   server 172.17.128.17:8080 weight=1;
}
    proxy_cache_path proxy_cache levels=1:2 keys_zone=page_cache:512m inactive=3d max_size=80g use_temp_path=off;
    proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
client_max_body_size 500m;
client_body_buffer_size 1024k;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
proxy_connect_timeout 300s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffer_size 128k;#设置代理服务器(nginx)保存用户头信息的缓冲区大小
proxy_buffers 4 128k;
proxy_busy_buffers_size 128k;    #高负荷下缓冲大小(proxy_buffers*2)
proxy_temp_file_write_size 256k;
proxy_ignore_client_abort on;
    server {
        listen       80;
        server_name  localhost;
        charset utf-8;
        #access_log  logs/host.access.log  main;
        location /qysb {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://app;
        }
        location / {
            proxy_redirect off;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            #proxy_pass http://app;
        root  html;
        }
        #error_page  404              /404.html;
        # redirect server error pages to the static page /50x.html
        proxy_intercept_errors on;
        error_page 400 403  500 502 503 504  /a.html;
        location = /a.html {
            root   /opt/qysb-mgr/webapps/qysb-mgr/jsp/wap/tips;
        }
        # 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 Apaches document root
        # concurs with nginxs one
        #
        #location ~ /.ht {
        #    deny  all;
        #}
    }
    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;
    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;
    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}

 

以上是关于自定义Nginx返回页面的主要内容,如果未能解决你的问题,请参考以下文章

HTML代码片段

HTML代码片段

Sublime Text3自定义代码片段

片段:按下返回按钮并自定义它时调用哪个回调

自定义对话框片段

自定义404报错页面