I’m running Caddy in a container as a reverse proxy for another container in which is running a nodejs application.
a. System environment:
Docker on Ubuntu.
b. Command:
docker-compose up -d --build
c. Service/unit/compose file:
docker and docker-compose
Dockerfile of the nodejs app
# Use Node.js 14 Alpine
FROM node:14-alpine as base
WORKDIR /src
COPY package*.json ./
EXPOSE 3000
FROM base as production
ENV NODE_ENV=production
#RUN npm ci
RUN npm install --quiet
COPY . ./
CMD ["node", "server.js"]
Does node server.js actually run a file server as well, or does it output the assets as static files?
If you need to serve static files, then you’ll need to make sure Caddy has a volume that gives it access to the files, then configure Caddy with the root + file_server directives to serve the static files, probably with a file matcher to only serve requests to files that exist on disk. Something like this:
Hello @francislavoie and thanks for your answer. The node application actually is a basic node express application that is serving an index.html file on the port 3000.
Well, the 404 comes from your node app, not from Caddy. So either adjust your node app to properly respond to requests to static files, or configure Caddy to serve the static files.