Skip to content

Instantly share code, notes, and snippets.

@rrei
Last active April 12, 2025 18:35
Show Gist options
  • Save rrei/1dd4337d05620e93f2f8477d7bf2025a to your computer and use it in GitHub Desktop.
Save rrei/1dd4337d05620e93f2f8477d7bf2025a to your computer and use it in GitHub Desktop.
Nginx proxy headers
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # allows django to get the client's IP address (see the ipware module)
proxy_set_header X-Forwarded-Proto $scheme; # allows django to determine that the request is secure (see SECURE_PROXY_SSL_HEADER and request.is_secure())
proxy_set_header X-Forwarded-Host $host; # allows django to determine the name/addr of the server that the client originally connected to (see request.get_host())
proxy_set_header X-Forwarded-Port $server_port; # same idea as above, but for port number (see request.get_port())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment