python - 从烧瓶中获取nginx的端口号
问题描述
我有一个 nginx 服务器在端口 5015 上侦听(在我的域上,http://foobar.com;也就是说,URL 是http://foobar.com:5015),代理到端口 8095 上的烧瓶应用程序,在我的 nginx 配置文件中使用这个:
server {
listen 5015;
server_name foobar.com;
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:8095/;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_cache cache;
proxy_cache_bypass $cookie_auth_tkt;
proxy_no_cache $cookie_auth_tkt;
proxy_cache_valid 30m;
proxy_cache_key $host$scheme$proxy_host$request_uri;
}
}
一切都很好,但我想在索引页面上的烧瓶中打印完整的 URL(包括端口号)。我已经尝试了这个答案中的所有属性,但只foobar.com
打印过。
我对此很困惑。
对于request.host
,文档说:
发出请求的主机名,包括非标准端口。
5015(如果它使用 nginx URL)和 8095(如果它使用代理 URL)都不是标准端口(据我所知!)。
有人可以解释发生了什么,以及是否可以http://foobar.com:5015
从任何Request
属性中打印烧瓶?
解决方案
推荐阅读
- mysql - 酒店预订系统,用sql查询查找免费房间的问题
- stripe-payments - 新 Stripe Checkout 中的税率
- javascript - 运行 Type Script 代码时出现未定义的错误
- skype - 在本地网络上设置 Skype 业务
- c# - 在 DbSet 内部查询
- reactjs - 即使我没有收到错误,React FilePond(功能组件)插件也不起作用?
- c++ - 浮点运算是否会导致 IEC 559/IEEE 754 浮点类型的无限未定义行为
- javascript - 手风琴内的莫里斯图表显示不正确
- c - get_cpu_var、put_cpu_var 不更新 Per CPU 变量
- android - 如何注销谷歌身份验证?