views:

176

answers:

3

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

+6  A: 

Given everything you're concerned with is clear HTTP (unlike something like AJP for instance) I'd run a protocol analyser such as Wireshark on the host and determine at which point the redirect is introduced.

Danny Thomas
+2  A: 

Check the error logs. On Linux mine are at /var/log/apache2. Just running a search for error.log should turn it up.

John
+2  A: 

The trick is here, that Django, nginx and Apache all need to be aware that they're on non-standard ports and react accordingly. (Assuming they are.) Like the comments suggest - some config information would really go a long way in helping us help you. (Ports+bindings for Apache and nginx).

It could be something as simple as:
(a) The FORM action is absolute and isn't getting re-written with the port (action="domain:port/folder/submit.cgi") [check page source]
(b) The FORM action target page is blank/implied (action="domain:port/folder/") which Apache would normally fix, but nginx misidentifies this as a cacheable/cached page rather than referring to Apache.

Questions:
1. Does form-GET work with same elements?
2. Are you using relative URLs or absolute URLs for the form-action attribute?
3. When viewing the source of the offending page, does the form-action include domain and port? (Or just relative URL)
4. When viewing the source of the offending page, does the form-action include a target file, or just an implied one?
5. When doing a form submit does the nginx log see the POST (sounds like yes - logs will reveal) does the Apache log see the POST (apache logs will show browser hitting the page and with which verb).

Rudu