Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the minor problems encountered in superset nginx reverse proxy configuration

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

How to solve the small problems encountered in superset nginx reverse proxy configuration, many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

When configuring superset reverse proxy with nginx and shunting through cookie with map, I encountered a very strange problem. When visiting the home page, I was always redirected to the domain name of upstream with the same name.

Upstream release {server 127.0.0.1 upstream development 8088 weight=1 max_fails=1 fail_timeout=30s;} upstream development {server 127.0.1 VR 8089 weight=1 max_fails=1 fail_timeout=30s;} map $COOKIE_version $env {default release; release release; development development;} server {listen 10001; server_name localhost; location / {proxy_pass http://$env; Proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_http_version 1.1; proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; send_timeout 600; proxy_set_header X-Forwarded-For $remote_addr;}}

The results are as follows

Curl-I http://127.0.0.1:10001/HTTP/1.1 302 FOUNDServer: nginx/1.17.1Date: Thu, 15 Aug 2019 07:54:44 GMTContent-Type: text/html; charset=utf-8Content-Length: 241Connection: keep-aliveLocation: http://release/superset/welcome / / here is the redirected header

For a time, I thought that the latest version of nginx had bug in the definition of map and upstream, but after thinking about it, it seemed impossible, and then from the analysis of the result performance and the general behavior of programmers (superset code is very complex, plus the flexible scripting language addition of python, I really don't want to turn over its code), it should be read the host header in the agent, then location, and then see this sentence in the nginx proxy document.

Allows redefining or appending fields to the request header passed to the proxied server. The value can contain text, variables, and their combinations. These directives are inherited from the previous level if and only if there are no proxy_set_header directives defined on the current level. By default, only two fields are redefined:

Proxy_set_header Host $proxy_host;proxy_set_header Connection close

The riddle has been solved.

By adding this to the proxy configuration, you can pass the original Host to superset

Proxy_set_header Host $http_host;curl-I http://127.0.0.1:10001/HTTP/1.1 302 FOUNDServer: nginx/1.17.1Date: Thu, 15 Aug 2019 08:06:47 GMTContent-Type: text/html; charset=utf-8Content-Length: 241Connection: keep-aliveLocation: http://127.0.0.1:10001/superset/welcome, will it help you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report