1、反向代理
server {.....location /demo {proxy_pass http://localhost:10008/demo;port_in_redirect on;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_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";}location /test {alias /home/web/build/; index index.html;}}
location /resource { expires 24h;if ($request_filename ~* ^.*?.(txt|doc|pdf|rar|gz|zip|rar|docx|exe|xlsx|xls|ppt|pptx)$){ add_header Content-Disposition attachment; } add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Headers X-Requested-With; add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS; alias /root/java/testweb/resource; autoindex on; }