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

Manually Clear from Console / Command Line cPanel Exim Mail Queue

To clear the cPanel exim mail queue quickly from a command line / shell use the following...

Whitelisting Multiple IPs with Mod_Security

The following can be added to the main modsecurity.conf or a whitelist file such as one...

Account's error_log produces flood of missing modules

 Account's error_log produces flood of missing modules. Ex:   From error_log:     [23-Apr-2018...

Create CXS Quarantine Directory

The following command may be used to create a quarantine directory for Configserver's CXS: cxs...

FSCK Options and Maintenance

Provided below are some useful commands pertaining to FSCK. Update commands to your environment /...