Unable to proxy to angular app through nginx as reverse proxy

Discussão em 'Angular' iniciado por bas, Fevereiro 13, 2025.

  1. bas

    bas Guest

    Trying to reverse proxy with nginx.

    I have a server which is hosting docker containers. One of them is hosting an Angular app (http).

    I setup my router to port forward to the host. The hosts forwards the port to the docker container. This does not involve nginx. This works.

    Then, I try to let nginx to act as reverse proxy. nginx is using certificates (generated with certbot, all straight forward).

    First step, let the server block show set a root and show some welcome page.

    location /projects-admin/ {
    alias /var/www/html/;
    index index.html;
    }



    when I browse to the server (https://mysupersecureserver/projects-admin) this shows my "hello world" page.

    Now, all I want to do is let it proxy pass to the localhost port which will be forwarded to my docker container.

    location /projects-admin/ {
    # rewrite ^/projects-admin/(/.*)$ $1 break;
    proxy_pass http://127.0.0.1:8090/;
    proxy_set_header Host $host;
    # proxy_set_header Upgrade $http_upgrade;
    # proxy_set_header Connection 'upgrade';
    # 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;
    }



    But whatever I try (note all the commented lines), it keeps complaining about the same thing in the logs


    2025/02/13 21:21:29 [error] 3626613#3626613: *1 open() "/usr/share/nginx/html/main.ac74cc2fb07d40a2.js" failed (2: No such file or directory), client: xxxxxxxxx, server: xxxxxxxx, request: "GET /main.ac74cc2fb07d40a2.js HTTP/1.1", host: "xxxxxxxxx", referrer: "xxxxxxxx/projects-admin/"
    ​

    I left out my real ip address and real dns name (xxxxxxx), because it's all kind of open at the moment for testing purposes.

    Anyway, I am a bit thrown off by the error, because it's the exact correct location inside the docker container, the files it tries to resolve are there!

    Am I missing something really obvious here?

    Really hope something can point me in the right direction

    Continue reading...

Compartilhe esta Página