From 0012d89a8277e78bd721d58a41a9df4d6f206320 Mon Sep 17 00:00:00 2001 From: wojiushixiaobai <296015668@qq.com> Date: Tue, 17 Aug 2021 15:25:55 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96nginx?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- configs/jms-nginx/nginx.conf | 163 +++++++++++++------------------- templates/deployment-nginx.yaml | 2 +- 2 files changed, 68 insertions(+), 97 deletions(-) diff --git a/configs/jms-nginx/nginx.conf b/configs/jms-nginx/nginx.conf index a356c71..2eb9528 100644 --- a/configs/jms-nginx/nginx.conf +++ b/configs/jms-nginx/nginx.conf @@ -2,103 +2,74 @@ {{- $lion := printf "http://%s-%s:%s" (include "jumpserver.fullname" $) "jms-lion" ($.Values.lion.service.web.port | toString) }} {{- $web := printf "http://%s-%s:%s" (include "jumpserver.fullname" $) "jms-core" ($.Values.core.service.web.port | toString) }} {{- $ws := printf "http://%s-%s:%s" (include "jumpserver.fullname" $) "jms-core" ($.Values.core.service.ws.port | toString) }} -user nginx; -worker_processes auto; -error_log /var/log/nginx/error.log; -pid /run/nginx.pid; +server { + listen {{ $.Values.nginx.service.web.port }}; + server_name _; + server_tokens off; -include /usr/share/nginx/modules/*.conf; + client_max_body_size 4096m; # 录像及文件上传大小限制 -events { - worker_connections 1024; -} - -http { - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for" "$upstream_addr"'; - - access_log /var/log/nginx/access.log main; - # access_log off; - - sendfile on; - tcp_nopush on; - tcp_nodelay on; - keepalive_timeout 65; - types_hash_max_size 2048; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - # include /etc/nginx/conf.d/*.conf; - - server { - listen {{ $.Values.nginx.service.web.port }}; - server_name _; - - client_max_body_size 4096m; # 录像及文件上传大小限制 - - location /ui/ { - try_files $uri / /index.html; - alias /opt/lina/; - } - location /luna/ { - try_files $uri / /index.html; - alias /opt/luna/; - } - location /media/ { - add_header Content-Encoding gzip; - root /opt/jumpserver/data/; - } - location /static/ { - root /opt/jumpserver/data/; - } - location /koko/ { - proxy_pass {{$koko}}; - proxy_buffering off; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - location /lion/ { - proxy_pass {{$lion}}; - proxy_buffering off; - proxy_http_version 1.1; - proxy_request_buffering off; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $http_connection; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - location /ws/ { - proxy_pass {{$ws}}; - proxy_buffering off; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - location /api/ { - proxy_pass {{$web}}; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - location /core/ { - proxy_pass {{$web}}; - proxy_buffering off; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - location / { - rewrite ^/(.*)$ /ui/$1 last; - } + location /ui/ { + try_files $uri / /index.html; + alias /opt/lina/; + } + location /luna/ { + try_files $uri / /index.html; + alias /opt/luna/; + } + location /media/ { + add_header Content-Encoding gzip; + root /opt/jumpserver/data/; + } + location /static/ { + root /opt/jumpserver/data/; + } + location /koko/ { + proxy_pass {{$koko}}; + proxy_buffering off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location /lion/ { + proxy_pass {{$lion}}; + proxy_buffering off; + proxy_http_version 1.1; + proxy_request_buffering off; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $http_connection; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location /ws/ { + proxy_pass {{$ws}}; + proxy_buffering off; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location /api/ { + proxy_pass {{$web}}; + proxy_buffering off; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location /core/ { + proxy_pass {{$web}}; + proxy_buffering off; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + location / { + rewrite ^/(.*)$ /ui/$1 last; } } diff --git a/templates/deployment-nginx.yaml b/templates/deployment-nginx.yaml index b5589a3..5473b5e 100644 --- a/templates/deployment-nginx.yaml +++ b/templates/deployment-nginx.yaml @@ -52,7 +52,7 @@ spec: resources: {{- toYaml .resources | nindent 12 }} volumeMounts: - - mountPath: "/etc/nginx/nginx.conf" + - mountPath: "/etc/nginx/conf.d/default.conf" name: "jms-nginx-config" subPath: "nginx.conf" - mountPath: "/opt/jumpserver/data"