I've got a Flask website which was running fine on a test-machine which I just call with an ip-address. I now deployed some new code, and url_for('index', _external=True)
suddenly gives out an address in which it lists the (correct) ip address twice with a comma in between:
http://52.29.15.xxx,52.29.15.xxx/
I have no SERVER_NAME
defined in my config.py
(which used to work fine until today) and I'm running on gunicorn behind an nginx server.
I tried adding SERVER_NAME = '52.29.15.xx'
to my config.py, but then I get a 404 on every url I try (and so the website doesn't work at all anymore).
I guess the problem lies in nginx which passes along a weird location or something?
Does anybody know how I can solve this? All tips are welcome!
Okay, after some fiddling around I found I had an error in my nginx config. I actually had the following two lines in two places in my config (which is why I didn't notice it):
proxy_set_header Host $http_host;
proxy_set_header Host $host;
which caused the ip address to appear twice in the Flask request context.
I now removed the first line, and everything works beautifully again.. :-)