Nginx redirecting folder to another host or server

From time to time you may want to proxy out a path to another server or location. To perform a proxy with nginx including frontend only nginx use, edit the vhost file for the domain you would like to make the modification to and add the following above the location / {:


# /folder redirect to remote account
    location ^~ /folder/ {
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwared-For $proxy_add_x_forwarded_for;
        proxy_intercept_errors on;
        proxy_pass http://remoteIP_or_hostname/;
}


Once saved restart nginx. Note, not all scripts will be happy about this configuration but we have found it to be the most friendly of the possible forwards.

  • 163 Users Found This Useful

Was this answer helpful?

Related Articles

Error: rpmdb open failed with cPanel

This can occur with older packages sitting on your drive. Try running the following: rm -f...

error: db3 error(-) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery

error: db3 error(-) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery...

Remount /tmp with exec permission

There are times where you may need to have exec permission available for the /tmp folder. This...

connection failed for acme-v01-api-letsencrypt org: SSL connect attempt failed

 (Hypertext Transfer Protocol) “post” request to...

Disable cPanel Brute Force Command Line

To disable the cPanel brute force detection from the command line usee the following:...