user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/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 /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; gzip_min_length 10240; gzip_comp_level 6; server { listen 5531; server_name localhost; #access_log /var/log/nginx/host.access.log main; location / { # add_header Cache-Control no-cache; # add_header Access-Control-Allow-Origin *; # add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS'; # add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'; # 将以.html结尾的请求添加Cache-Control头信息 if ($uri ~* \.(html)$) { add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate"; } root /usr/share/nginx/html/out; index index.html index.htm *.html; # try_files $uri $uri/ /index.html; # 默认情况下,根据路径转发,找不到加载index.html try_files $uri /$uri.html /index.html; } #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 /usr/share/nginx/html; } } # include /etc/nginx/conf.d/*.conf; }