0

I've been struggling for 3 days with Nginx reverse proxy to realize i think, a easy thing. I have to simply reach many backend node-red (nodeJS) application from Nginx but always, with different ports.

For the next, this my example :

Web client -> `https://ip_adr/1881/ui/` -> Nginx proxy_pass `http://127.0.0.1:1881/ui/` (app)

Backend app serves pictures on http://127.0.0.1:1881/*.jpg


  1. I realise a static test with :
location / {
        #proxy_pass http://127.0.0.1:1881;
}

https://ip_adress/ui in my browser running well with all app pictures.

  1. With rewrite to forward the port from frontend to backend, dynamically :

    location ~ ^/(?<port>\d\d\d\d) {
    
        rewrite "^/\d{4}/(.*)" /$1 break;
        proxy_pass http://127.0.0.1:$port;
    

    }

With the regex, i extract port from ip_adr/1881 with /(?<port>\d\d\d\d), and rewrite url without /1881 but keeping eventualy /path1/path2/...

If i put https://192.168.x.x/1881/ui/ in my browser everything good but WITHOUT pictures.


After many and many tests, my browser don't display any images, and the trace error log say me for all picture :

2022/03/10 01:01:36 [error] 50065#50065: *1224 open() "/usr/share/nginx/html/schema_fire_EEU.jpg" failed (2: No such file or directory), client: 192.168.1.29, server: exemple3.test.fr, request: "GET /schema_fire_EEU.jpg HTTP/1.1", host: "192.168.1.53", referrer: "https://192.168.1.53/1881/ui/"

That is very incredible, if i put https://192.168.x.x/1881/schema_fire_EEU.jpg, i can display this image !!!

I think, there is a problem with slash ...

Someone can help me ?

Have a good day ;-)

  • 1
    Duplicate of [nginx reverse proxy IP\_adr/1881 to localhost:1881 proxy\_pass](https://serverfault.com/questions/1095645/nginx-reverse-proxy-ip-adr-1881-to-localhost1881-proxy-pass) – djdomi Mar 10 '22 at 17:40
  • Sorry but, not the same ;-) – dinastar66 Mar 10 '22 at 20:01

1 Answers1

0

From my understanding of what you're saying the problem could be that the URI to which you are proxying it's not right.

If this "https://192.168.x.x/1881/schema_fire_EEU.jpg" works means that your service is exposing your image under "/", but the ProxyPass rule does not have the "/".

You could try with:

ProxyPass / http://ip:port

Have a nice day. :)