Answer the question
In order to leave comments, you need to log in
How to deploy django project to nginx subpath?
There is a project on django built in a docker container, together with nginx it is assembled in docker-compose, on the IP address to which the port is forwarded.
It looks like this
ipaddress : 84 in this case everything works fine .
the host machine and holds the main site, for example example.com/my_app
But if you do a regular proxy_pass in the host nginx, then all the application urls go astray, and you need to hardcode the 'my_app' prefix in them, but I would like to avoid this
Here are the configs:
Nginx on the host
server {
server_name example.com;
location /my_app{
proxy_pass http://ip_address:84;
}
}
upstream db {
server app:8000;
}
server {
listen 80;
server_name ip_address;
location / {
proxy_pass http://app:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
}
}
Answer the question
In order to leave comments, you need to log in
server {
server_name example.com;
location ^~ /my_app/ {
proxy_pass http://ip_address:84/;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question