Reverse Proxy for the internal DNS to an external IP or URL

May 23, 2018 3.2k views
Apache Nginx DNS Linux Commands

Is there a possibility to configure reverse proxy for a DNS record to an external URL where an application is hosted. If yes, how to configure it on already installed Nginx.

1 Answer

The example configuration below should do the trick but is pretty basic. A more verbose configuration that addresses some common issues with this type of setup can be found here.

server {

       listen 80 default_server;
       listen [::]:80 default_server;

        root /var/www/html;

        index index.html index.htm index.nginx-debian.html;
        server_name _;

        location / {
        proxy_pass http://remote.application.url;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;


Have another answer? Share your knowledge.