0

I am hosting two apps (a custom "Notes" app, and File browser) on my raspberry pi with nginx. I set a reverse proxy so I can access notes on localhost/notes and files on localhost/files. I can land on both app, but it seems that both frontend make requests to an api with route /api/..., and my login request on File Browser returns a 404. How can I ensure api requests are proxied to the correct "/api" backend ?

Here is my nginx config file at this point :

server {
    listen 80;
    listen 443;

    # Notes
    root /var/www;
    index index.html;

    location /notes {
        root /var/www;
        try_files $uri $uri/ /notes/index.html;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    # Notes API
    location /api/ {
        proxy_pass http://127.0.0.1:8000/;
    }


    # File browser
    location /files/ {
        proxy_pass http://localhost:8084/;
        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;
        proxy_redirect off;

        # Rewriting URLs for File Browser
        rewrite ^/files/(.*)$ /$1 break;
    }


    location /static/ {
        proxy_pass http://localhost:8084/static/;
        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;
        proxy_redirect off;     
    }
}

Also, I added a proxy for File Browser static assets that works, but how should I do in case I host another apps that needs static assets on the same route ?

0

You must log in to answer this question.

Browse other questions tagged .