This is currently my setup:
publicly available private network
__________________________ ______________________________
| Traefik reverse proxy | <--> | nginx <--> Django/GUnicorn |
__________________________ ______________________________
The Traefik proxy forwards a publicly available URL like https://some.example.com/foo/bar/ to http://<ip-of-nginx>:80/ (i.e. it strips the components foo and bar and downgrades from https to http). nginx serves static files and also acts internally as another reverse proxy, forwarding back and forth to the Django web application.
When a client requests https://some.example.com/foo/bar/baz, he is delivered the site at http://<ip-of-nginx>:80/baz, which is the site rendered by Django for the route /baz (as expected). However, all links on that site point to https://some.example.com/…, without the foo/bar/ part. Such links are not covered by Traefik and therefore broken. Additionally, static content like images also are not displayed.
To summarize: Forwarding works partially (some parts of the website are delivered), however links and static content are broken.
How do I setup this properly? In more detail:
- Is stripping
foo/bar/in general a good idea, or should I instead also use it in Django? - If stripping is a good idea, where to perform it? Already at Traefik, or only at nginx?
- Is nginx's config the right place to address the broken link issue, or is Django/GUnicorn the right spot?