score:1

try using this config to build the docker

# build environment
from node:9.6.1 as builder
run mkdir /usr/src/app
workdir /usr/src/app
env path /usr/src/app/node_modules/.bin:$path
copy package.json /usr/src/app/package.json
run npm install --silent
run npm install react-scripts@1.1.1 -g --silent
copy . /usr/src/app
run npm run build

# production environment
from nginx:1.13.9-alpine
copy --from=builder /usr/src/app/build /usr/share/nginx/html
expose 80
cmd ["nginx", "-g", "daemon off;"]

never had any problem using this script. u might miss some nginx config or forgot to copy recursively, who knows if u didnt post the dockerfile

*note: i didnt make it
credit: https://mherman.org/blog/dockerizing-a-react-app/

score:1

i think this is an elegant solution for nginx reverse proxy cofiguration.

/etc/nginx/sites-available/app2.conf

server {
    listen 80;
    listen [::]:80;

    server_name example.com www.example.com;

    location / {
            proxy_pass http://localhost:3001;

            # recommended settings
            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;
    }
}

don't forget symbolic link:

sudo ln -s /etc/nginx/sites-available/app2.conf /etc/nginx/sites-enabled/ 

score:2

please check this https://docs.nginx.com/nginx/admin-guide/web-server/serving-static-content/

you have to specify the way static files are to served depending upon the url requested for static files.

hope it helps!


Related Query

More Query from same tag