Score:0

nginx reverse proxy IP_adr/1881 to localhost:1881 proxy_pass

cn flag

I have read this post, and try many thing but i have issue with rewrite regex. here

I have many node.js processes as backends with always different port to access.

With Nginx reverse proxy in the same server i want to pass for exemple : https://my-site/1881 to http://127.0.0.1:1881 proxy_pass.

I can get 1881 from my-site/1881 but i have always at the end 127.0.0.1:1881/1881. Or Nginx error. I don't knows exactly how to delete /1881 with rewrite.

That i tried :

location ~ ^/(?<port>\d\d\d\d)$ {            #Ok

        rewrite "^/[0-9]{4}(.*)$" $1 break;  #try and retry here
        proxy_pass http://127.0.0.1:$port;   #Ok
}

Thank you for your help, have a good day

djdomi avatar
za flag
i think / is missing on the end since else it will afaik a relatively url
dinastar66 avatar
cn flag
No, i have always 127.0.0.1:1881/1881 :-(
Score:0
cn flag

Ok,

I'm running with :

location ~ ^/(?<port>\d\d\d\d) {

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

}

And working well but now not displaying any picture :-(

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.