nginx.conf 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. #user nobody;
  2. worker_processes 1;
  3. #error_log logs/error.log;
  4. #error_log logs/error.log notice;
  5. #error_log logs/error.log info;
  6. #pid logs/nginx.pid;
  7. events {
  8. worker_connections 1024;
  9. }
  10. http {
  11. include mime.types;
  12. default_type application/octet-stream;
  13. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  14. # '$status $body_bytes_sent "$http_referer" '
  15. # '"$http_user_agent" "$http_x_forwarded_for"';
  16. #access_log logs/access.log main;
  17. sendfile on;
  18. #tcp_nopush on;
  19. #keepalive_timeout 0;
  20. keepalive_timeout 65;
  21. #gzip on;
  22. upstream appservice {
  23. server localhost:8080;
  24. }
  25. upstream oauth2 {
  26. server localhost:8081;
  27. }
  28. upstream websocketws {
  29. server localhost:3016;
  30. }
  31. upstream imservice {
  32. server localhost:3017;
  33. }
  34. server {
  35. listen 3006 backlog=1024;
  36. index index.html;
  37. server_name localhost;
  38. root /data/src/remote/h5;
  39. gzip on;
  40. gzip_disable "msie6";
  41. # access_log /var/log/nginx/ws.access.log main;
  42. # error_log /var/log/nginx/ws.error.log;
  43. location / {
  44. proxy_pass http://websocketws;
  45. proxy_http_version 1.1;
  46. proxy_set_header Upgrade $http_upgrade;
  47. proxy_set_header Connection "Upgrade";
  48. proxy_connect_timeout 5;
  49. proxy_read_timeout 60;
  50. proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
  51. }
  52. }
  53. server {
  54. listen 80;
  55. server_name localhost;
  56. #charset koi8-r;
  57. #access_log logs/host.access.log main;
  58. location / {
  59. add_header 'Access-Control-Allow-Origin' '*';
  60. add_header 'Access-Control-Allow-Credentials' 'true';
  61. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  62. add_header 'Access-Control-Allow-Headers' 'sn, Content-Type';
  63. add_header 'Access-Control-Expose-Headers' 'sn, Origin, X-Requested-With, Content-Type, Accept, Authorization';
  64. add_header 'Access-Control-Allow-Headers' 'X-Custom-Header, Origin, X-Requested-With, Content-Type, Accept, Authorization';
  65. proxy_redirect off;
  66. proxy_set_header Host $host;
  67. proxy_set_header X-Real-IP $remote_addr;
  68. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  69. proxy_set_header Referer $http_referer;
  70. proxy_pass http://appservice;
  71. proxy_http_version 1.1;
  72. proxy_set_header Connection "";
  73. client_max_body_size 1000m;
  74. proxy_connect_timeout 5;
  75. proxy_read_timeout 60;
  76. proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
  77. }
  78. location ~ ^/(acc|oauth)/ {
  79. add_header 'Access-Control-Allow-Origin' '$http_origin';
  80. add_header 'Access-Control-Allow-Credentials' 'true';
  81. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  82. add_header 'Access-Control-Allow-Headers' 'sn, Content-Type';
  83. add_header 'Access-Control-Expose-Headers' 'sn, Origin, X-Requested-With, Content-Type, Accept, Authorization';
  84. add_header 'Access-Control-Allow-Headers' 'X-Custom-Header, Origin, X-Requested-With, Content-Type, Accept, Authorization';
  85. proxy_redirect off;
  86. proxy_set_header Host $host;
  87. proxy_set_header X-Real-IP $remote_addr;
  88. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  89. proxy_set_header Referer $http_referer;
  90. proxy_pass http://oauth2;
  91. proxy_http_version 1.1;
  92. proxy_set_header Connection "";
  93. client_max_body_size 1000m;
  94. proxy_connect_timeout 10;
  95. proxy_read_timeout 10;
  96. proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
  97. }
  98. location ~ ^/(imroom|imtest|iminnerapi|test)/ {
  99. #add_header 'Access-Control-Allow-Origin' '*';
  100. #add_header 'Access-Control-Allow-Credentials' 'true';
  101. #add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  102. #add_header 'Access-Control-Allow-Headers' 'sn, Content-Type';
  103. #add_header 'Access-Control-Expose-Headers' 'sn, Origin, X-Requested-With, Content-Type, Accept, Authorization';
  104. #add_header 'Access-Control-Allow-Headers' 'X-Custom-Header, Origin, X-Requested-With, Content-Type, Accept, Authorization';
  105. proxy_redirect off;
  106. proxy_set_header Host $host;
  107. proxy_set_header X-Real-IP $remote_addr;
  108. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  109. proxy_set_header Referer $http_referer;
  110. proxy_pass http://imservice;
  111. proxy_http_version 1.1;
  112. proxy_set_header Connection "";
  113. client_max_body_size 1000m;
  114. proxy_connect_timeout 5;
  115. proxy_read_timeout 60;
  116. proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504 http_404;
  117. }
  118. }
  119. # another virtual host using mix of IP-, name-, and port-based configuration
  120. #
  121. #server {
  122. # listen 8000;
  123. # listen somename:8080;
  124. # server_name somename alias another.alias;
  125. # location / {
  126. # root html;
  127. # index index.html index.htm;
  128. # }
  129. #}
  130. # HTTPS server
  131. #
  132. #server {
  133. # listen 443 ssl;
  134. # server_name localhost;
  135. # ssl_certificate cert.pem;
  136. # ssl_certificate_key cert.key;
  137. # ssl_session_cache shared:SSL:1m;
  138. # ssl_session_timeout 5m;
  139. # ssl_ciphers HIGH:!aNULL:!MD5;
  140. # ssl_prefer_server_ciphers on;
  141. # location / {
  142. # root html;
  143. # index index.html index.htm;
  144. # }
  145. #}
  146. }