For development purposal I would like to implement this: Dockerized strapi app
But there is a problem with routing to /dashboard/. It should load static files from strapi container, which is not doing. I think that problem occures because of bad Nginx configuration . Here is my default.conf file:
upstream client {
# CRA dev server
server client:3000;
}
upstream strapi {
# strapi server
server strapi:1337;
}
server {
listen 80;
location / {
proxy_pass http://client;
}
location /sockjs-node {
proxy_pass http://client;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
# Strapi API and Admin
location /api/v1/ {
rewrite ^/api/v1(.*)$ /$1 break;
proxy_pass http://strapi;
proxy_http_version 1.1;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass_request_headers on;
}
# Strapi Admin panel
location /dashboard/ {
proxy_pass http://strapi/dashboard/;
}
}
and here is docker-compose.dev.yaml file
version: '3'
services:
nginx:
restart: always
container_name: nginx
build:
dockerfile: Dockerfile.dev
context: ./nginx
ports:
- '3050:80'
depends_on:
- client
- strapi
networks:
- api-network
strapi:
image: strapi/strapi
container_name: strapi
restart: unless-stopped
environment:
NODE_ENV: development
DATABASE_CLIENT: mongo
DATABASE_NAME: strapidata
DATABASE_HOST: strapidata
DATABASE_PORT: 27017
DATABASE_USERNAME:
DATABASE_PASSWORD:
networks:
- api-network
volumes:
- ./strapi:/srv/app
ports:
- '1337:1337'
depends_on:
- strapidata
strapidata:
image: mongo
container_name: strapidata
restart: unless-stopped
environment:
MONGO_INITDB_ROOT_USERNAME:
MONGO_INITDB_ROOT_PASSWORD:
networks:
- api-network
volumes:
- ./mongoDB:/data/db
ports:
- '27017:27017'
client:
container_name: client
build:
context: ./client
dockerfile: Dockerfile.dev
volumes:
- /app/node_modules
- ./client:/app
ports:
- 3000:3000
environment:
- CHOKIDAR_USEPOLLING=true
stdin_open: true
tty: true
depends_on:
- strapi
networks:
- api-network
networks:
api-network:
driver: bridge
NGINX=> api/v1/ works perfect, but it is not passing assets for /dashboard/. Assets from strapi container are not loaded to /dashboard. Did someone tried that?