1. upstream node_app {
  2. server 127.0.0.1:8085;
  3. }
  4. server {
  5. listen 80;
  6. server_name admin.play.youliao.xunlei.com;
  7. error_log /var/log/nginx/test.play.youliao.xunlei.com_error.log;
  8. access_log /var/log/nginx/test.play.youliao.xunlei.com_access.log;
  9. index index.html index.htm index.php;
  10. location / {
  11. proxy_set_header X-Real-IP $remote_addr;
  12. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  13. proxy_set_header Host $http_host;
  14. proxy_set_header X-Nginx-Proxy true;
  15. proxy_set_header Connection "";
  16. proxy_pass http://node_app;
  17. }
  18. }
  19. server {
  20. listen 80;
  21. server_name play.youliao.xunlei.com localhost;
  22. root /usr/share/nginx/html/youliao.play;
  23. index index.php index.html;
  24. ssi on;
  25. ssi_silent_errors on;
  26. ssi_types text/shtml;
  27. location / {
  28. try_files $uri $uri/ /index.php?$query_string;
  29. }
  30. expires -1;
  31. error_log /var/log/nginx/test.play.youliao.xunlei.com_error.log;
  32. access_log /var/log/nginx/test.play.youliao.xunlei.com_access.log;
  33. chunked_transfer_encoding off;
  34. client_max_body_size 300m;
  35. location ~ \.php$ {
  36. fastcgi_pass 127.0.0.1:9000;
  37. fastcgi_connect_timeout 300;
  38. fastcgi_send_timeout 300;
  39. fastcgi_read_timeout 300;
  40. fastcgi_buffer_size 16k;
  41. fastcgi_buffers 32 16k;
  42. fastcgi_index index.php;
  43. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  44. fastcgi_param CI_ENV 'development';
  45. if ($request_method = 'GET') {
  46. add_header 'Access-Control-Allow-Origin' http://localhost:8085;
  47. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  48. add_header Access-Control-Allow-Credentials true;
  49. #add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  50. }
  51. if ($request_method = 'POST') {
  52. add_header Access-Control-Allow-Origin http://localhost:8085;
  53. #add_header Access-Control-Allow-Origin * always;
  54. add_header Access-Control-Allow-Headers X-Requested-With;
  55. add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
  56. add_header Access-Control-Allow-Credentials true;
  57. }
  58. if ($request_method = 'OPTIONS') {
  59. add_header 'Access-Control-Allow-Origin' http://localhost:8085;
  60. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  61. add_header Access-Control-Allow-Credentials true;
  62. #
  63. # Custom headers and headers various browsers *should* be OK with but aren't
  64. #
  65. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  66. #
  67. # Tell client that this pre-flight info is valid for 20 days
  68. #
  69. add_header 'Access-Control-Max-Age' 2;
  70. add_header 'Content-Type' 'text/plain charset=UTF-8';
  71. add_header 'Content-Length' 0;
  72. return 204;
  73. }
  74. include fastcgi_params;
  75. }
  76. }

分类: web

标签:   nginx