nginx_aiportal.conf 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. user root;
  2. worker_processes 5;
  3. events {
  4. worker_connections 2048;
  5. }
  6. http {
  7. include mime.types;
  8. default_type application/octet-stream;
  9. server_tokens off;
  10. sendfile on;
  11. keepalive_timeout 65;
  12. gzip on;
  13. gzip_disable "msie6";
  14. gzip_min_length 1k;
  15. gzip_buffers 4 16k;
  16. gzip_http_version 1.0;
  17. gzip_comp_level 3;
  18. gzip_types text/plain
  19. application/x-javascript
  20. ext/css
  21. application/xml
  22. text/javascript
  23. image/jpeg
  24. image/gif
  25. image/png
  26. image/svg+xml
  27. application/font-woff
  28. application/javascript;
  29. gzip_vary on;
  30. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  31. '$status $body_bytes_sent "$http_referer" '
  32. '"$http_user_agent" "$http_x_forwarded_for"';
  33. map $http_upgrade $connection_upgrade {
  34. default upgrade;
  35. '' close;
  36. }
  37. upstream ws_speech_cn{
  38. hash $remote_addr consistent;
  39. server 10.1.251.211:5020;
  40. }
  41. upstream ws_speech_en{
  42. hash $remote_addr consistent;
  43. server 10.1.251.211:5030;
  44. }
  45. server {
  46. listen 8181;
  47. listen 443 ssl;
  48. charset utf-8;
  49. index index.html;
  50. root /usr/share/nginx/html/;
  51. # 增加ssl
  52. #ssl on; #如果强制HTTPs访问,这行要打开
  53. ssl_certificate /ssl/server.crt;
  54. ssl_certificate_key /ssl/server_nopwd.key;
  55. ssl_session_cache shared:SSL:1m;
  56. ssl_session_timeout 5m;
  57. # 指定密码为openssl支持的格式
  58. ssl_protocols SSLv2 SSLv3 TLSv1.2;
  59. ssl_ciphers HIGH:!aNULL:!MD5; # 密码加密方式
  60. ssl_prefer_server_ciphers on; # 依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码
  61. location = ${__WEB_CONTEXT_PATH}/ {
  62. return 301 /portal/;
  63. }
  64. location ~ .*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm)$ {
  65. expires 7d;
  66. add_header Pragma public;
  67. add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  68. }
  69. location ${__WEB_CONTEXT_PATH}/ {
  70. try_files $uri $uri/ /index.html;
  71. access_log on;
  72. }
  73. location /portal {
  74. try_files $uri $uri/ /portal/index.html;
  75. }
  76. location /data_images/portal/ {
  77. proxy_pass ${__GATEWAY_URL}/aiSquare/openApi/appscene/data_images/portal/;
  78. expires 7d;
  79. add_header Pragma public;
  80. add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  81. }
  82. location ^~ ${__WEB_CONTEXT_PATH}/assets/ {
  83. alias /usr/share/nginx/html/assets/;
  84. expires max;
  85. add_header Pragma public;
  86. add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  87. }
  88. location ^~ ${__WEB_CONTEXT_PATH}/images/ {
  89. alias /usr/share/nginx/html/images/;
  90. add_header Pragma public;
  91. add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  92. }
  93. location ^~ ${__WEB_CONTEXT_PATH}/docs/ {
  94. alias /usr/share/nginx/html/docs/;
  95. add_header Pragma public;
  96. add_header Cache-Control "public, must-revalidate, proxy-revalidate";
  97. }
  98. location /aiSquare/openApi/ {
  99. proxy_pass ${__GATEWAY_URL}/aiSquare/openApi/;
  100. proxy_set_header Host $host;
  101. proxy_set_header X-Real-IP $remote_addr;
  102. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  103. proxy_set_header X-Forwarded-Proto $scheme;
  104. access_log off;
  105. }
  106. location /text_translate_cn/{
  107. proxy_pass http://10.1.251.211:8080/text_translate_cn/;
  108. }
  109. location /text_translate_en/{
  110. proxy_pass http://10.1.251.211:8080/text_translate_en/;
  111. }
  112. location /speech_cn/{
  113. proxy_pass http://ws_speech_cn/speech/;
  114. proxy_set_header Host $host:$server_port;
  115. proxy_http_version 1.1;
  116. proxy_set_header Upgrade $http_upgrade;
  117. proxy_set_header Connection "Upgrade";
  118. proxy_connect_timeout 4s;
  119. proxy_read_timeout 60s;
  120. proxy_send_timeout 12s;
  121. }
  122. location /speech_en/{
  123. proxy_pass http://ws_speech_en/speech/;
  124. proxy_set_header Host $host:$server_port;
  125. proxy_http_version 1.1;
  126. proxy_set_header Upgrade $http_upgrade;
  127. proxy_set_header Connection "Upgrade";
  128. proxy_connect_timeout 4s;
  129. proxy_read_timeout 60s;
  130. proxy_send_timeout 12s;
  131. }
  132. error_page 404 = ${__WEB_CONTEXT_PATH}/notFound;
  133. location = ${__WEB_CONTEXT_PATH}/notFound {
  134. root /usr/share/nginx/html;
  135. }
  136. access_log /data/ai_lab/ai_web/logs/web-access.log main;
  137. }
  138. }