Http POST丢弃URL中的端口 [英] Http POST drops port in URL
问题描述
我将路由器配置为将发送到特定端口的所有流量路由到该笔记本电脑。
我有Nginx作为Apache的反向代理,使用mod_wsgi运行Django。
我的问题是这样的:当我尝试提交任何POST表单时,端口#从url(例如209.245.23.201:1552/login/成为209.245.23.201/login /)
自然,这样会中断。是什么原因导致了这个问题(Nginx,Apache,Django?),如何修复?
提前感谢
编辑:表单看起来提交,但我认为重定向失败。
编辑2:问题肯定是与Nginx,或Nginx和Apache。我尝试安装Apache作为唯一的服务器,运行django,它工作正常。所以任何一个Nginx都在丢弃端口,或者某种程度上,Apache正在被Nginx用作代理而感到困惑。无论
我有与我的开发服务器相同的问题。
经过一些互联网搜索,我发现了这个讨论( nginx,apache和奇怪的管理员错误)解决方案是修改nginx的代理配置。
要修改的配置设置是:
proxy_set_header Host $ host;
解决方案是添加端口号:
$ pre>
proxy_set_header Host $ host:$ server_port;
在我的ngnix + apache2(与工作mpm)+ django现在都很好。
I have a webapp built with Django. I'm currently running it off a laptop at home behind a router.
I have the router configured to route all traffic sent to a specific port to that laptop.
I have Nginx as a reverse proxy for Apache, using mod_wsgi to run Django.
My problem is this: when I try to submit any POST form, the port # gets removed from the url (e.g. 209.245.23.201:1552/login/ becomes 209.245.23.201/login/)
Naturally, this breaks. What causes this (Nginx, Apache, Django?) and how can I fix it?
Thanks in advance.
EDIT: It appears that the forms DO submit, but I think the redirect fails.
EDIT 2: The problem is definitely either with Nginx, or the interaction between Nginx and Apache. I tried the setup with Apache as the only server, running django, and it worked fine. So either Nginx is dropping the port, or somehow Apache is getting confused by Nginx acting as the proxy.whatever
I have the same problem with my development server. After some internet search I've found this discussion (nginx, apache, and odd admin error) where the solution is to modify the proxy configuration of nginx.
The configuration setting to modify is:
proxy_set_header Host $host;
the solution is to add the port number:
proxy_set_header Host $host:$server_port;
In my ngnix + apache2 (with worker mpm) + django now all works well.
这篇关于Http POST丢弃URL中的端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!