Ricardo
Ricardo

Reputation: 127

Nginx Reverse proxy translate domain to ip

I'm new with nginx, but i'm trying to build a reverse proxy that could do something like this:

Whenever a request arrives to a domain name like this in my nginx reverse proxy server: http://dn.55-32.mydomain.name/path/file.cfg

Parse the 55-32 and forward the request to an internal ip. http://10.10.55.32/path/file.cfg

The 55-32 represent that las octects XX.XX.55.32 to the forwarded server. Is there a way to build such a behavior?

Upvotes: 0

Views: 1004

Answers (1)

Ricardo
Ricardo

Reputation: 127

Finally i made it wokr with this configuration:

server {
        listen       443 ssl http2 default_server;

        server_name ~^dn\.(?<octet1>.+)-(?<octet2>.+)\.mydomain\.com$;

        location / {
                set $var http://10.10.$octet1.$octet2;
                proxy_pass $var;
        }
}

Maybe this could be helpful for someone...

Ricardo

Upvotes: 2

Related Questions