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
- 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.
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 ;-)