#錯誤頁面優化顯示 注意將下面兩個圖片上傳至服務器中php
error_page 500 501 502 503 504 http://www.abc.com/error2.jpg;css
error_page 400 403 404 405 408 410 412 413 414 415 http://www.abc.com/error1.jpg;html
[root@web01 ~]# cat /application/nginx/conf/extra/www.conf server { listen 80; server_name www.abc.com; rewrite ^(.*)$ https://$host$1 permanent; } server { listen 443; server_name www.abc.com; root html/www; index index.php index.html index.htm; #https證書 ssl on; ssl_certificate /application/nginx/conf/key/server.crt; ssl_certificate_key /application/nginx/conf/key/server.key; #訪問日誌 access_log logs/access_www.log main; #隱藏版本號 server_tokens on; ##防盜鏈 #location ~* .*\.(jpg|gif|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar)$ { #小括號中不能包含要跳轉的圖片結尾格式.png,-->不然會進入死循環跳轉 # valid_referers none blocked *.abc.com abc.com www.abc.com; # if ($invalid_referer) { # #return 403; # rewrite ^/ https://www.abc.com/fangdaolian.png; # } #} #客戶端對靜態內容緩存 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30y; root html/www; } location ~ .*\.(js|css)?$ { expires 30d; root html/www; } #php解析 location ~ .*\.(php|php5)?$ { root html/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; #FastCGI 相關參數調優 #fastcgi_cache ngx_fcgi_cache; fastcgi_cache_valid 200 302 1h; fastcgi_cache_valid 301 1d; fastcgi_cache_valid any 1m; fastcgi_cache_min_uses 1; fastcgi_cache_use_stale error timeout invalid_header http_500; fastcgi_cache_key http://$host$request_uri; } #錯誤頁面優化顯示 注意將下面兩個圖片上傳至服務器中 error_page 500 501 502 503 504 http://www.abc.com/error2.jpg; error_page 400 403 404 405 408 410 412 413 414 415 http://www.abc.com/error1.jpg; }