123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- server {
- #服務部屬上Container用的是哪個Port
- listen 80;
- server_name localhost;
- client_max_body_size 2000M;
- client_body_buffer_size 128k;
- proxy_connect_timeout 5;
- proxy_send_timeout 1800;
- proxy_read_timeout 1800;
- proxy_buffer_size 4k;
- proxy_buffers 4 32k;
- proxy_busy_buffers_size 64k;
- proxy_temp_file_write_size 64k;
- auth_basic "status";
- #開啟gzip
- gzip on;
- #低於1kb的資源不壓縮
- gzip_min_length 1k;
- #壓縮級別1-9,越大壓縮率越高,同時消耗cpu資源也越多,建議設置在5左右。
- gzip_comp_level 5;
- #需要壓縮哪些response類型的資源,用空格隔開。不建議壓縮圖片.
- gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
- #配置禁用gzip條件,支持正規表達式。此處表示ie6及以下不啟用gzip
- gzip_disable "MSIE [1-6]\.";
- #是否添加"Vary: Accept-Encoding" response header
- gzip_vary on;
- #location / 是指當從外部訪問這個服務的時候,他需要帶什麼路徑 (這邊寫是localhost:7777/)
- #如果希望是訪問的網址是 localhost:7777/myWeb 就寫成location /myWeb
- # location /admin {
- # root /usr/share/nginx/html/admin;
- # index index.html index.htm;
- # try_files $uri $uri/ /index.html;
- # }
-
- location / {
- root /usr/share/nginx/html;
- index index.html index.htm;
- try_files $uri $uri/ /index.html;
- }
- # 二级目录配置(/subdir)
- location /admin {
- alias /usr/share/nginx/html/admin; # 子应用的静态文件目录
- index index.html;
- client_max_body_size 2000M;
- try_files $uri $uri/ /admin/index.html;
- }
- # # 防止二级目录下的静态资源被错误处理
- location /admin/ {
- alias /usr/share/nginx/html/admin/;
- try_files $uri $uri/ =404;
- }
-
- # # 配置静态资源缓存
- # location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
- # expires 1y;
- # add_header Cache-Control "public";
- # }
- # 代理 API 请求到后端服务
- location /api/ {
- proxy_pass http://backend:8085/; # 后端 API 地址
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- client_max_body_size 2000M;
- # 如果需要支持 WebSocket,添加以下配置
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection "upgrade";
- }
-
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root /usr/share/nginx/html;
- }
- }
|