Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to proxy RDP via Nginx

I'm using the below config in nginx to proxy RDP connection:

  server { 
    listen          80;
    server_name     domain.com;

    location / {
      proxy_pass      http://192.168.0.100:3389;
    }
  }

but the connection doesn't go through. My guess is that the problem is http in proxy_pass. Googling "Nginx RDP" didn't yield much.

Anyone knows if it's possible and if yes how?

like image 371
fardin Avatar asked Mar 21 '18 19:03

fardin


1 Answers

Well actually you are right the http is the problem but not exactly that one in your code block. Lets explain it a bit:

In your nginx.conf file you have something similar to this:

http {  
    ...
    ...
    ...

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

So everything you write in your conf files are inside this http block/scope. But rdp is not http is a different protocol.

The only workaround I know for nginx to handle this is to work on tcp level.

So inside in your nginx.conf and outside the http block you have to declare the stream block like this:

stream {
    # ...
    server {
        listen     80;
        proxy_pass 192.168.0.100:3389;
    }
}

With the above configuration just proxying your backend on tcp layer with a cost of course. As you may notice its missing the server_name attribute you can't use it in the stream scope, plus you lose all the logging functionality that comes on the http level.

For more info on this topic check the docs

like image 68
zochamx Avatar answered Oct 19 '22 21:10

zochamx