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

Permission denied: /home/username/ htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable

When checking your error log you find the error 508 or 403 forbidden error in your browser and...

yum-utils not installed or found on Centos5 64-bit

When yum-utils is not installed or found on Centos5 64-bit the following commands may be used:...

How to convert InnoDB to MyISAM

Although at times faster, you will find InnoDB a very large headache when it comes to table...

This webpage is not available ERR_SSL_VERSION_OR_CIPHER_MISMATCH

This webpage is not availableERR_SSL_VERSION_OR_CIPHER_MISMATCHA secure connection cannot be...

Clear cPanel Eximstats DB and Repairing the Eximstats DB

Over the time or due to spammers the eximstats database file may grow to a large size. To clear...