I have two websites site1 and site2 on the same VPS server (same IP).

Now I am going to use Nginx as a reverse sever for both of them. site1 has already used port 80, which runs no problem so far. But when I configure site2 to use port 81 or 82. Nginx can only display/direct part of the website correctly not all of it. For example, it can render the homepage using port 81 without problem. But some links on that page or some button still point to a URL with port 80 (the default port). I can make sure both sites runs fine locally. How can I make site2 run correctly using a port other than 80?

1 Answer 1


There is a command proxy_rediect

So in Nginx configuration we will write

 proxy_redirect original_url:80 redirect_url:port;

In this way Nginx will redirect all the requests to the default port to another port.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .