How to permanently redirect port 8080 URL to port 80 using nginx

17,517
server {
    listen www.domain.com:8080;
    server_name  www.domain.com;
    rewrite ^ http://www.domain.com permanent;    
}

Should do it.

Share:
17,517

Related videos on Youtube

Alex
Author by

Alex

Updated on September 17, 2022

Comments

  • Alex
    Alex over 1 year

    Because of my carelessness, I put http://www.domain.com:8080/xxx/index.html on the internet. I don't want to lose that traffic, so i want to permanent redirect that url to http://www.domain.com/xxx/index.html Can nginx achieve this? thanks

    • Martin Fjordvald
      Martin Fjordvald over 13 years
      Click the check mark under the answer that was the best.
  • Jon Rhoades
    Jon Rhoades over 13 years
    Unless you really need the extra folder path - /xxx/index.html
  • Martin Fjordvald
    Martin Fjordvald over 13 years
    in which case rewrite ^ domain.com$request_uri permanent; would do it.