I have a Python/Django API with a unique endpoint /videos
running on my Debian server.
The Nginx vhost looks like this:
server {
server_name example.com;
location / {
# Pass to Uvicorn/Gunicorn web server service
proxy_pass http://upstream_name/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /path_to/fullchain.pem; # managed by Certbot
ssl_certificate_key /path_to/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
upstream upstream_name {
server 127.0.0.1:8002;
}
Thus, it successfully serve the app and its unique endpoint on https://example.com/videos
.
Now, I would like to serve the app on https://example.com/my_app/videos
, in order to have in the future a other apps served on the same domain/vhost (with different internal ports, different upstreams in the vhost of course).
I've been reading several similar Q/A on ServerFault, and have been trying changing location /
to location /my_app
, while trying different trailing slashes configs on location
and proxy_pass
, with no success. What am I missing here?
EDIT: More precisely:
With the vhost changed to location /myapp
-> https://example.com/my_app/videos
displays a Not Found error (not from Nginx)
With the vhost changed to location /my_app/
-> https://example.com/my_app/videos
get redirected to https://example.com/videos/
and displays a 404 Not Found error (from Nginx)