Running multiple docker containers and node apps on single nginx server (problem with serving asserts)
21:53 22 Feb 2026

I have a node app running on port 3500 and a docker container react app on port 3501.

Here is the nginx configuration:

server {
    server_name domain.com www.domain.com;

    location / {
    proxy_pass http://localhost:3500;
        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 /sudoku/ {
        proxy_pass http://localhost:3501/;
        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;
    }
.
.
.
}

And the Dockerfile

# BUILD THE APP

FROM node:22.14.0 AS build

# Make non-root group
RUN groupadd -r notroot && useradd -r -g notroot -m notroot

# Set work directory
WORKDIR /app

# Copy all package json files (package.json and package-lock.json)
COPY package*.json ./

# Set notroot ownership of workdir
RUN chown -R notroot .

# Set user to non-root
USER notroot

# Install modules (in this order to make use of caching)
RUN npm install

# Copy the rest of the files
COPY --chown=notroot:notroot . .

# Build the app
RUN npm run build



# SERVE STATIC FILES WITH NGINX

FROM nginx:alpine

# Copy static files to nginx html
COPY --from=build /app/dist /usr/share/nginx/html

# Expose port 80 (http)
EXPOSE 80

# Start nginx
CMD ["nginx", "-g", "daemon off;"]

The problem is when accessing /sudoku, react app cannot get the assets (js and css files). I did read about and tried to set the homepage: "/sudoku" in package.json, but that doesn't work either (of course i rebuilt the image).

This is my preferred way of doing it, since I plan on adding more apps. Is there a way to configure this, or should i do it some other way?

reactjs node.js docker nginx