Saturday, 27 August 2016

Nginx sample config to proxy a port


Sample Nginx config for proxying a port

Many a times you may encounter a need to proxy a port in Nginx. For example, you may want a process running on a port other than port 80 to listen request from outside world through port 80 without exposing the actual port. This could be achieved with a simple location block in Nginx which is shown below.

Just replace the your-domain.com to the actual domain and the proxy_pass value to the actual IP and port. If your process is bind with private IP than replace the 127.0.0.1 with the private IP


server {
    listen 80;
    server_name your-domain.com;
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:2368;
    }
}

0 comments:

Post a Comment

 

Copyright @ 2013 Appychip.

Designed by Appychip & YouTube Channel