From 72b5207ab4167d2449ef908fe7692ac78f43cf25 Mon Sep 17 00:00:00 2001 From: lbbniu Date: Thu, 8 Sep 2022 17:34:14 +0800 Subject: [PATCH] pref: optimized nginx configuration --- deploy/craned/deployment.yaml | 54 +++++++++-------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/deploy/craned/deployment.yaml b/deploy/craned/deployment.yaml index 459543a1d..2061e320f 100644 --- a/deploy/craned/deployment.yaml +++ b/deploy/craned/deployment.yaml @@ -150,6 +150,17 @@ metadata: name: nginx-conf namespace: crane-system data: + common_params: | + proxy_connect_timeout 180; + proxy_send_timeout 180; + proxy_read_timeout 180; + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Host $http_host; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection $connection_upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; nginx.conf: | gzip_static on; @@ -214,50 +225,13 @@ data: } location /grafana { set $upstream_grafana grafana.crane-system.svc.cluster.local; - proxy_connect_timeout 180; - proxy_send_timeout 180; - proxy_read_timeout 180; proxy_pass http://$upstream_grafana:8082; - proxy_redirect off; rewrite /grafana/(.*) /$1 break; - proxy_http_version 1.1; - proxy_set_header Host $http_host; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection $connection_upgrade; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - location /api/v1/cluster { - proxy_connect_timeout 180; - proxy_send_timeout 180; - proxy_read_timeout 180; - proxy_pass http://cluster; - proxy_redirect off; - proxy_http_version 1.1; - proxy_set_header Connection ""; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - } - location /api/v1/namespaces { - proxy_connect_timeout 180; - proxy_send_timeout 180; - proxy_read_timeout 180; - proxy_pass http://cluster; - proxy_redirect off; - proxy_http_version 1.1; - proxy_set_header Connection ""; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + include conf.d/common_params; } + # merge /api/v1/cluster /api/v1/namespaces location /api { - proxy_connect_timeout 180; - proxy_send_timeout 180; - proxy_read_timeout 180; proxy_pass http://cluster; - proxy_redirect off; - proxy_http_version 1.1; - proxy_set_header Connection ""; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + include conf.d/common_params; } }