python - 如何从烧瓶应用程序获取请求 url?
问题描述
我在服务器上有一个烧瓶应用程序。该烧瓶应用程序使用该代码启动。
app.run(host="0.0.0.0",debug=True, port=3001,threaded=True)
当我尝试使用服务器公共 IP 访问该应用程序时。我可以获得完整的标题。我得到带有dict(request.headers)
.
在我的 dockerhost 上,我有 30 个容器,它们看起来与烧瓶应用程序的地址相同。我的意思是;
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 设置是;对于码头集装箱:
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。
解决方案
推荐阅读
- c# - Unity3d - 更改天空盒颜色时反射不会更新
- perforce - perforce:如何检查最近(半年期间)修改的文件以及修改这些文件的人
- haskell - 如何返回在 Haskell 编程中交替组合两个函数列表产生的函数?
- android - 我可以在执行航点任务时向任何方向旋转飞机偏航吗?
- python - Django中多对多字段的PATCH
- ios - 使用 Socket 从浏览器读取请求后如何发送响应?(我正在使用 SwiftSocket)
- python - 我怎样才能让这段代码不仅仅包含循环中的第一次出现?
- c - 我的平衡支架解决方案有什么问题?
- android - 为什么广播接收器不能在服务内部连续工作
- java - Kafka Streams:刷新中间窗口结果,因为提交间隔和窗口时间不同步