nginx代理

  1. upstream web {
  2. server 127.0.0.1:8787;
  3. keepalive 10240;
  4. }
  5. server {
  6. server_name yoursite.com;
  7. listen 80;
  8. root /www/yoursite/public;
  9. location / {
  10. index index.html;
  11. proxy_http_version 1.1;
  12. proxy_set_header Connection "";
  13. proxy_set_header X-Real-Ip $remote_addr;
  14. proxy_set_header Host $http_host;
  15. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  16. proxy_set_header X-Forwarded-Proto $scheme;
  17. if (!-e $request_filename)
  18. {
  19. proxy_pass http://web;
  20. }
  21. }
  22. location = / {
  23. proxy_http_version 1.1;
  24. proxy_set_header Connection "";
  25. proxy_set_header X-Real-Ip $remote_addr;
  26. proxy_set_header Host $http_host;
  27. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  28. proxy_set_header X-Forwarded-Proto $scheme;
  29. proxy_pass http://web;
  30. }
  31. }