English is not my native language.
I have three Next.js apps, each with their own static file directory(.next
) and I want to config Nginx the way it find the required static files.
here is my current Nginx config.
location /_next {
alias /.../users-front/.next;
}
location /fonts {
alias /.../users-front/public/fonts;
}
location /{
include proxy_params;
#proxy_pass http://unix:/run/gunicorn.sock;
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /doctors {
rewrite ^/doctors/(.*)$ /$1 break;
include proxy_params;
#proxy_pass http://unix:/run/gunicorn.sock;
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /users {
rewrite ^/users/(.*)$ /$1 break;
include proxy_params;
#proxy_pass http://unix:/run/gunicorn.sock;
proxy_pass http://localhost:3002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
I'm not a frontend developer or senior devops, I have to do this and I don't know how!
the three apps are named "users-front", "authors-front" and "landing". all of them send static file requests to /_next
.
I tried this and it didn't work
location /_next {
try_files $uri
/path/to/app1/.next$uri
/path/to/app2/.next$uri
/path/to/app3/.next$uri
=404; # Return 404 if not found in any location
}