Was wondering if there was a way to prepend all URLs with a particular URL. I'll explain the challenge, perhaps I'm going about it all wrong:
Imagine I have three sites all built using Django that are run using nginx and within separate docker containers: main_site, project1 and project2.
When navigating to https://main_site
, this should load the pages in main_site as normal.
But when navigating to https://main_site/projects/project_1/
,
This should navigate to project 1.
And similarly, when navigating to https://main_site/projects/project_2/
, this should load the pages from project 2.
I've managed to make this somewhat work using nginx and docker.
I have rules something along the lines of:
location / {
proxy_pass http://main_site;
}
location /projects/project_1 {
proxy_pass http://project_1;
}
location /projects/project_2 {
proxy_pass http://project_2;
}
This works perfectly for the homepage (minus the static assets).
But, whenever we use template tags in Django, the links in creates is always relative to root (/something/
), whenever on any link, it takes me back to the main_site.
I get why this is happening, because everything is happening on the same port.
Question is, is there a way to prepend a URL to all the URLs (static assets as well) without fundamentally having to add reverse or something. I don't want to have to manually add the link to all pages.
Or, does anyone know of a better way to overcome this challenge?