Skip to content

Commit

Permalink
fix(server): use protocol forwarded by nginx (#562)
Browse files Browse the repository at this point in the history
nginx wasn't passing the protocol being used to Django, which was
causing it to treat all requests as unencrypted HTTP. Add config and
make Django respect the forwarded protocol.

Fixes #562
  • Loading branch information
ericswpark committed Aug 17, 2024
1 parent b147fed commit 7407cd1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions docker/nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ server {

proxy_pass http://shipper;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_redirect off;
}
Expand Down
3 changes: 3 additions & 0 deletions server/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@

SECURE_HSTS_SECONDS = int(os.environ.get("SHIPPER_SECURE_HSTS_SECONDS", default=0))

SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")


with open("version.txt") as v_file:
SHIPPER_VERSION = v_file.readline().rstrip()

Expand Down

0 comments on commit 7407cd1

Please sign in to comment.