Redirect to the home page in nginx Redirect to the home page in nginx nginx nginx

Redirect to the home page in nginx


You should add a location = / block to force the root URI to home. For example:

server {    listen 443 ssl;    server_name myapp.io www.myapp.io;    ssl_certificate ...;    ssl_certificate_key ...;    ...    location = / {        return 301 /home;    }    location ~ /.well-known {        allow all;    }    location / {        proxy_set_header    Host                $host;        proxy_set_header    X-Forwarded-For     $proxy_add_x_forwarded_for;        proxy_set_header    X-Forwarded-Proto   $scheme;        proxy_set_header    Accept-Encoding     "";        proxy_set_header    Proxy               "";        proxy_pass          https://127.0.0.1:3000;        proxy_http_version 1.1;        proxy_set_header   Upgrade $http_upgrade;        proxy_set_header   Connection "upgrade";    }}