Question

How To Redirect IP Reverse Proxy Nginx To New IP Nginx

Can help me for How To Redirect IP Reverse Proxy Nginx To New IP Nginx ? Thanks For your answer :)


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

KFSys
Site Moderator
Site Moderator badge
April 22, 2022

Hi @littleturquoiseship,

In order to do a redirect to another IP address, all you need to do is add a simple snippet of code in your Nginx config file:

server {
   listen 80 default_server;
   listen [::]:80 default_server;
   server_name domain.com www.domain.com;
   
   return 301 IPAddress;
}

Alternatively, if you want to redirect as reverse proxy (to another port), what you can do is

server {
    listen 80 default_server;
    server_name domain.com;


    location / {
            proxy_pass http://123.123.123.1:41002/$uri;
            proxy_set_header Host $host;
    }
}

So, first you’ll need to change domain.com with your actual domain, 123.123.123.1 with the IP address you want to redirect it to as well as the port 41002 to your needs.