1

I have a scenario hope that someone will help me with that

So the scenario is i have a server that is reachable to the internet and some server that are connected to my lan (In the private network) so what i want is when some one try to connect to a domain in my network i want it to be redirected to another server in the private network

So what i want is if in rdp whn.domain.com is stated than that should be to first the server exposed in the internet

than to the private ip ---> 192.168.71.1

similarly,

whm.domain.com ---> 192.168.71.2
whh.domain.com ----> 192.168.71.3

currently in my nginx.conf i have

stream {
    # ...
    server {
        listen     3389;
        proxy_pass 192.168.72.13:3389;
    }
}

so now what it is doing is any request to my server with port 3389 is redirected to one single ip

Now i want to check the domain that it has been pointing to and then tranfer it to that ip

i want something like

stream {
    # ...
    server {
        listen     3389;
        server_name whm.domain.com
        proxy_pass 192.168.71.1:3389;
    }
    server {
        listen     3389;
        server_name whn.domain.com
        proxy_pass 192.168.71.1:3389;
    }
}

But the stream context doesnt support server_name directive so any idea how can i achive this

1
  • serverfault.com/questions/628147/… . Requires the relevant information to be carried in the TLS ClientHello message (so TLS encryption is mandatory for the method in the link).
    – A.B
    Apr 26, 2021 at 11:29

1 Answer 1

0

Its possible to use the map directive and ngx_stream_ssl_preread_module:

stream {
    log_format basic '$remote_addr [$time_local] '
                     '$protocol $status $bytes_sent $bytes_received '
                     '$session_time';

    access_log  "/var/log/$ssl_preread_server_name-access.log" basic;
    error_log   "/var/log/$ssl_preread_server_name-error.log"  info;

    map $ssl_preread_server_name $name {
        hostnames;
        # map ssl_preread_server_name to name
        whm.domain.com  192.168.71.1:3389;
        whn.domain.com  192.168.71.1:3389;
    }

    server {
        listen 3389;
        ssl_preread on;
        proxy_pass $name:$server_port;
        proxy_buffer_size 64k;
        proxy_connect_timeout 60s;
    }
}

with map you can use different backend servers and ports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.