adamchainz / django-browser-reload

Automatically reload your browser in development.
MIT License
507 stars 26 forks source link

Add to docs - NGINX proxy support #242

Closed geemang2022 closed 7 months ago

geemang2022 commented 7 months ago

Description

I had an issue with reloads working when I had an NGINX proxy in front of DJANGO.

NOTE: web is the django service in my docker-compose file

upstream web {
  server web:8000;
}

server {
...
  location /__reload__ {
    proxy_pass http://web;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header SSL_PROTOCOL https;
    add_header X-DEBUG-RELOAD 1 always;
    proxy_set_header Host   $host;

    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header Connection '';
    proxy_set_header Cache-Control 'no-cache';
    chunked_transfer_encoding off;
  }

 location / {
   proxy_pass http://web;
   ... 
 }
}
adamchainz commented 7 months ago

Thanks for sharing. Most Django projects I’ve seen don’t use nginx in front of runserver during development.

There are many web servers and I don’t want to maintain documentation specific to just one, nginx, so I don’t think it’s worth adding to the README. But people searching nginx in the issue tracker can find your configuration.

Cheers!