How to deploy nextjs into a directory which is not a root directory
Your current config tells nginx to map urls 1-to-1, that means that /next/what-ever
will be mapped to http://localhost:3000/next/what-ever
.
To solve this you need to add an additional slash.
server { ... location /next/ { proxy_pass http://localhost:3000/ // <---- this last slash tells to drop the prefix }}
For more info read https://docs.nginx.com/nginx/admin-guide/web-server/reverse-proxy/#passing-a-request-to-a-proxied-server