需求:如果访问404就跳到指定页面。
http { include /etc/tengine/mime.types; default_type text/html; access_log /data/log/nginx/access.log; sendfile on; server_tokens off; keepalive_timeout 120; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; tcp_nopush on; client_max_body_size 50m; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; fastcgi_buffers 4 128k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; fastcgi_temp_path /dev/shm; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; upstream backend { server 10.10.10.45:11214 max_fails=1 fail_timeout=30s; server 10.10.10.46:11214 max_fails=1 fail_timeout=30s; } server { listen 80; server_name www.ijinshan.com; location / { root /data/app/www.ijinshan.com; index index.html index.htm; } location /liebao { set $memc_key $arg_key; memc_pass backend; memc_cmds_allowed get; access_log /data/logs/access.log; error_page 404 = @view404; } location @view404{ root /data/app/www.ijinshan.com; rewrite ^/(.*) /index.html last; } } }
转载于:https://blog.51cto.com/navyaijm/1206462