Welcome! Log In Create A New Profile

Advanced

Dinamyc ip based reverse proxy

Posted by leostereo 
Dinamyc ip based reverse proxy
January 31, 2019 09:53AM
Hi guys, Im new using nginx , I would like to try the reverse proxy feature.
I need to achieve this:
Lets supose my nginx server is at 10.1.1.254 , I would like to forward my request according to url data , for example:

If I request http://10.1.1.254/192.168.100.1. The reverse proxy should bring http://192.168.100.1.

So far I build some server block , according to some readings but it is not working.
This is what I have:

server {
listen 80;
server_name localhost;

location ~ /\b(?:\d{1,3}\.){3}\d{1,3}\b/ {
proxy_pass http://$1;
}

}

Note:
the regexp : /\b(?:\d{1,3}\.){3}\d{1,3}\b/ has succesfully been tested with pcretest:

re> /\b(?:\d{1,3}\.){3}\d{1,3}\b/
data> 192.168.100.2
0: 192.168.100.2

But:
Nginx claims that can not compile filter:
[emerg] 7659#7659: pcre_compile() failed: missing ) in "\b(?:\d" in>e

Ok ... Any idea would be wellcome,
Leandro.
Re: Dinamyc ip based reverse proxy
January 31, 2019 02:24PM
I make some improvements: using following server block:

server {
listen 8888;
server_name modem;

location ~ /(.*) {
proxy_pass http://$1;
}

}

It seems to be working but something is missing.
I can see that my browser is receiving data , and set the tab tittle but it can not complete all the web page.
In other cases it prints part of the page.
I dont know if the problem is related to javascript , routing ...

Any idea is wellcome.
Leandro.
Re: Dinamyc ip based reverse proxy
February 01, 2019 02:05PM
Other thing ...
It works if I use a hardcoded ip, like this :

server {
listen 8888;
server_name tozed;

location / {
proxy_pass http://100.65.36.95;
}

}

And in the broser I do:
http:8888/tozed

It brings all the web content ...

Regards.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 211
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready