nginx.default.conf 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. server {
  2. listen 80;
  3. server_name localhost;
  4. access_log /data/log/nginx/access.log main;
  5. error_log /data/log/nginx/error.log;
  6. # 静态资源
  7. location / {
  8. root /data/web;
  9. index index.html index.htm;
  10. try_files $uri $uri/ /index.html;
  11. }
  12. # 前端代理
  13. location ^~ /后端服务名 {
  14. proxy_pass http://后端服务IP地址:8080;
  15. add_header Access-Control-Allow-Origin *;
  16. add_header Access-Control-Allow-Credentials: true;
  17. add_header Access-Control-Allow-Methods GET,POST,OPTIONS,PUT,DELETE;
  18. proxy_http_version 1.1;
  19. # 连接延时
  20. proxy_connect_timeout 3600s;
  21. proxy_read_timeout 3600s;
  22. proxy_send_timeout 3600s;
  23. # IP 穿透
  24. proxy_set_header Host $proxy_host;
  25. proxy_set_header X-Real-IP $remote_addr;
  26. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  27. # WebSocket 穿透
  28. proxy_set_header Origin "";
  29. proxy_set_header Upgrade $http_upgrade;
  30. proxy_set_header Connection "upgrade";
  31. }
  32. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  33. #location ~ \.php$ {
  34. # root html;
  35. # fastcgi_pass 127.0.0.1:9000;
  36. # fastcgi_index index.php;
  37. # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  38. # include fastcgi_params;
  39. #}
  40. }