Next.js Discord

Discord Forum

Got 403 forbidden when I want serve it by Nginx

Unanswered
White-crowned Pigeon posted this in #help-forum
Open in Discord
Avatar
White-crowned PigeonOP
I have Netjs project on our local gitlab, I clone this project on my linux desktop and run this command
'''yarn build'''
after that move .next to
'''/usr/share/nginx/html/call'''
after that I make this for ngnix server
'''server {
listen 10007;
#server_name testnextdeploy.com www.testnextdeploy.com;
root /usr/share/nginx/html/call-center;

location / {
try_files $uri $uri/ /_next/$uri /index.html;
}

location /_next {
alias /usr/share/nginx/html/call-center/.next;
try_files $uri $uri/;
}

location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
'''
and after that restart nginx

but when I go to browser and type 192.168.1.90:10007

I got this error

'''403 Forbidden / nginx/1.14.1
'''
and I see this in error log of nginx
'''
2023/09/09 10:00:21 [error] 889200#0: *1 directory index of "/usr/share/nginx/html/call/" is forbidden, client: 1.2.3.4, server: , request: "GET / HTTP/1.1", host: "192.168.1.90:10007"
2023/09/09 10:00:22 [error] 889200#0: *1 directory index of "/usr/share/nginx/html/call/" is forbidden, client: 1.2.3.4, server: , request: "GET / HTTP/1.1", host: "192.168.1.90:10007"
'''
and nginx can not serve this nextjs project.

permission of files and folder of nextjs project serve by nginx is OK , I have another projects on this server and all of them serve by nginx without problem.

0 Replies