realpython / dockerizing-django

https://realpython.com/blog/python/django-development-with-docker-compose-and-machine/
1.34k stars 484 forks source link

Switch Nginx config to use $http_host #28

Closed ActionScripted closed 8 years ago

ActionScripted commented 8 years ago

Great, short explanation: http://stackoverflow.com/a/20752916/12276

I was running into errors with a slightly more complex Django setup of my own and this fixed things.

mjhea0 commented 8 years ago

Are you suggesting I change the nginx config?

ActionScripted commented 8 years ago

Yes, sorry for not being more clear or submitting a proper PR. Switching line 13 in nginx/sites-enabled/django_project from proxy_set_header Host $host; to proxy_set_header Host $http_host; will keep folks using frontnend forms and such from running into errors.

mjhea0 commented 8 years ago

Can you submit a quick PR? :)

ActionScripted commented 8 years ago

Wanted to be sure I wasn't missing something and in double-checking things I found that in docker-compose.yml I was mapping Nginx's port as "8080:80" which was causing problems.

$http_host fixed this but that was only treating a symptom. After reading more about whether $http_host was preferred to $host I've learned that $host is absolutely the way to go 99% of the time.

Closing this because it was a problem with my config and nothing with this repo. Thanks so much for being so polite and for the great article.

Related information:

mjhea0 commented 8 years ago

Thanks!