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

Posted May 23, 2018 19.8k views
NginxUbuntuCentOSApacheDNSLinux 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.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
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;