Score:1

NGINX can't find the index.html in any location

bd flag

I'm new at nginx and i'm trying to deploy a react application but things is not working very well.

I have my dist folder with my static files (index.html, css and js) in /home/ec2-user/difo/digital-input-for-operators-react/dist.

My default page of nginx is working well in port 80, but when i try to reach the port 3000 (which is the number that i put in the listen directive) i have 404 error page.

I tried difo.ucnet.g-ushin.com:3000, i got this:

server {
    listen 3000;
    server_name difo.ucnet.g-ushin.com localhost;
    access_log /etc/nginx/logs/difo-react.log;
    root /home/ec2-user/difo/digital-interfaces-for-operators-react/dist;
    index index.html index.htm;
    location / {
        try_files $uri $uri/ =404;
    }
}

Then i tried to create a simple html page to make some tests. I moved this new index.html to an new folder called page in the root folder of nginx and in my conf/server block i tried this:


server {
    listen 3000;
    server_name difo.ucnet.g-ushin.com localhost;
    access_log /etc/nginx/logs/difo-react.log;
    root page;
    index index.html index.htm;
    location / {
        try_files $uri $uri/ =404;
    }
}

And also dont work.

This is the logs:


10.23.7.153 - - [09/Nov/2022:14:39:19 +0000] "GET / HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"
10.23.7.153 - - [09/Nov/2022:14:44:05 +0000] "GET / HTTP/1.1" 404 555 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36"

Can someone help me try to understand how can i setup the server block in conf.d?

us flag
What does nginx error log show?
Guilherme Castello avatar
bd flag
I added the logs in the question.
Score:0
bd flag

I moved the dist folder to the same folder that nginx is getting the default index.html and worked. I guess is a permission problem.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.