nginx.conf 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 365;
  20. server_tokens off;
  21. #gzip on;
  22. gzip on;
  23. gzip_min_length 1k;
  24. gzip_buffers 4 16k;
  25. gzip_http_version 1.0;
  26. gzip_comp_level 6;
  27. gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
  28. gzip_vary on;
  29. server {
  30. listen 12101 default_server;
  31. server_name localhost;
  32. client_max_body_size 100M;
  33. fastcgi_intercept_errors on;
  34. error_page 403 /custom_403.html; #鑷畾涔夐敊璇〉闈?uri
  35. location = /custom_403.html {
  36. ssi on; # 浣縣tml鏀寔璇诲彇鍙橀噺
  37. ssi_silent_errors on; # 榛樿鍊兼槸off锛屽紑鍚悗鍦ㄥ鐞哠SI鏂囦欢鍑洪敊鏃朵笉杈撳嚭閿欒鎻愮ず
  38. add_header Content-Type 'text/html';
  39. add_header X-Frame-Options 'SAMEORIGIN';
  40. return 403 '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
  41. <html>
  42. <head><title>403 Forbidden</title></head>
  43. <body>
  44. <center><h1>403 Forbidden</h1></center>
  45. </body>
  46. </html>';
  47. }
  48. location / {
  49. gzip on;
  50. gzip_min_length 1k;
  51. gzip_buffers 4 16k;
  52. gzip_http_version 1.0;
  53. gzip_comp_level 2;
  54. gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
  55. gzip_vary on;
  56. # root /usr/share/nginx/html/;
  57. root /usr/share/nginx/html/industry-18099;
  58. # 鐢ㄤ簬閰嶅悎 browserHistory 浣跨敤
  59. try_files $uri $uri/ /index.html;
  60. index index.html index.htm;
  61. }
  62. location ~/industry-18099/ {
  63. gzip on;
  64. gzip_min_length 1k;
  65. gzip_buffers 4 16k;
  66. gzip_http_version 1.0;
  67. gzip_comp_level 2;
  68. gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
  69. gzip_vary on;
  70. root /usr/share/nginx/html;
  71. # 鐢ㄤ簬閰嶅悎 browserHistory 浣跨敤
  72. try_files $uri $uri/ /index.html;
  73. index index.html index.htm;
  74. }
  75. location /api/ {
  76. add_header 'Access-Control-Allow-Origin' $http_origin;
  77. add_header 'Access-Control-Allow-Headers' "*";
  78. add_header 'Access-Control-Allow-Credentials' 'true';
  79. add_header 'Access-Control-Allow-Methods' 'GET,POST';
  80. if ($request_uri ~* "captchaImage") {
  81. add_header 'Access-Control-Allow-Origin' 'http://10.38.26.119';
  82. }
  83. if ($request_method = OPTIONS) {
  84. add_header 'Access-Control-Allow-Origin' '*';
  85. add_header 'Access-Control-Allow-Methods' 'GET,POST,PUT,DELETE,PATCH';
  86. add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range,Referer,X-Frame-Options';
  87. add_header 'Access-Control-Max-Age' 1728000;
  88. add_header 'Content-Type' 'text/plain charset=UTF-8';
  89. add_header 'Content-Length' 0;
  90. return 204;
  91. }
  92. proxy_pass http://10.38.26.119:18080/; # edit test
  93. proxy_set_header X-Real-IP $remote_addr;
  94. proxy_set_header Host $http_host;
  95. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  96. proxy_read_timeout 600;
  97. }
  98. location ^~ /preview/ {
  99. add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  100. add_header 'Access-Control-Allow-Credentials' 'true' always;
  101. add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS' always;
  102. add_header 'Access-Control-Allow-Headers' 'Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified- Since,Keep-Alive,Origin,User-Agent,X-Requested-With' always;
  103. proxy_pass https://video-platform.obs.cn-north-4.myhuaweicloud.com/;
  104. }
  105. location /apiserver/ {
  106. add_header 'Access-Control-Allow-Origin' "$http_origin" always;
  107. add_header 'Access-Control-Allow-Credentials' 'true';
  108. add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS';
  109. proxy_pass http://10.38.26.119/api/; # M-gM-=M-^QM-eM-^EM-3M-eM-^FM-^EM-gM-=M-^QM-eM-^\M-0M-eM-^]M-^@M-gM-+M-/M-eM-^OM-#
  110. proxy_set_header X-Real-IP $remote_addr;
  111. proxy_set_header Host $http_host;
  112. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  113. proxy_read_timeout 600;
  114. }
  115. }
  116. }