1

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?

1 Answers1

0

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.