如何从Flask应用获取请求网址?

我在服务器上有一个flask应用程序。该烧瓶应用程序将使用该代码启动。

app.run(host="0.0.0.0",debug=True,port=3001,threaded=True)

当我尝试通过服务器公共IP访问该应用程序时。我可以获得完整的标题。 我得到dict(request.headers)的标题。

在我的dockerhost上,我有30个与flask应用程序具有相同地址的容器。我的意思是;

public-ip:3001 / test和my.sites.example.com/test去了那个烧瓶应用程序。 如果我拨打public-ip:3001 / test,则我将公共IP作为主机。当我致电my.sites.example.com/test时,我得到0.0.0.0:3001/test作为主机。我正在尝试获取my.sites.example.com。

我的nginx设置是;对于Docker容器:

  location /test/ {
    proxy_pass  http://0.0.0.0:3001/test/;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;
  }

对于服务器:

 location / {
      proxy_pass  http://127.0.0.1:3001/;
      proxy_set_header Host $http_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 https;
  }

我的主要目标是获取客户的请求网址。 public-ip:3001 / test和my.sites.example.com/test去了那个烧瓶应用程序。如果我拨打public-ip:3001 / test,则我将公共IP作为主机。当我致电my.sites.example.com/test时,我得到0.0.0.0:3001/test作为主机。我正在尝试获取my.sites.example.com。

b946241223 回答:如何从Flask应用获取请求网址?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3125546.html

大家都在问