Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am having two listener 80 and 777. Port 80 act as a reverse proxy. And port 777 does some extra stuff and want to redirect to port 80. How do I redirect to a different port in nginx? I was trying with rewrite but later figured out that it is only used for change of path

   ###
   server{
            listen  80;
            server_name     _;
            location / {
                    proxy_pass "http://upstream0;#" is included since links are not allowed in the post
            }

    }

    server{
            listen  777;
            server_name     _;
            #doing some other extra stuf
            //Want to redirect to port 80 under some condition
    }

Thanks

share|improve this question

1 Answer 1

return 302 $scheme://$server_name:80$request_uri;

That should do the trick.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.