Friday, 25 October 2019

Nginx Redirect: Return and Rewrite

Nginx redirect all using location+return:

server {
  listen ...;
  server_name ...;
  
  location ~* ^/(.*)$ {
    return 307 https://some.domain/$1;
  }
}

Nginx redirect all using rewrite:

server {
  listen ...;
  server_name ...;

  rewrite ^/(.*)$ https://some.domain/$1 redirect;
}

Nginx as proxy (to port 9999 for example):

server {
  listen ...;
  server_name ...;

  location / {
    proxy_pass http://localhost:9999;
  }
}

No comments:

Post a Comment