Score:0

Nginx reverse proxy reach my site but can't get pictures

cn flag

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

djdomi avatar
za flag
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)
dinastar66 avatar
cn flag
Sorry but, not the same ;-)
Score:0
cn flag

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

dinastar66 avatar
cn flag
Thank you but, rather ``proxy_pass http://127.0.0.1:$port/;`` ?
djdomi avatar
za flag
ProxyPass is Apache Syntax not Nginx
dinastar66 avatar
cn flag
Ok, but i can't get any picture anymore
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.