I created two applications (backend (fastapi. Works on 8000 port), frontend (reactjs. Works on 80 port)) they are communicate each with other.
My docker-compose file:
version: '3.7'
services:
frontend:
container_name: "frontend"
build:
context: ./frontend
stop_signal: SIGTERM
ports:
- "80:80"
volumes:
- ./uploads:/app/uploads
networks:
- good_network
depends_on:
- backend
backend:
container_name: "backend"
build:
context: ./backend
stop_signal: SIGTERM
ports:
- "8000:8000"
networks:
- good_network
volumes:
- ./uploads:/app/uploads
depends_on:
- postgres
postgres:
container_name: "postgres"
image: postgres:16.0
healthcheck:
test: [ "CMD-SHELL", "pg_isready -d sugar -U postgres" ]
interval: 5s
timeout: 5s
retries: 5
start_period: 5s
restart: unless-stopped
ports:
- "5432:5432"
volumes:
- ./postgres_data:/var/lib/postgresql/data
networks:
- good_network
networks:
good_network:
volumes:
postgres_data:
help me with configuration a certificate :(.
My tries:
uvicorn.run(..., ssl_keyfile="./privkey.pem", ssl_certfile="./fullchain.pem") # Problem with cors :/
I’ve tried to use certbot, but i created a certfiles, but i didn’t understand what to do with it…
2
Answers
I sloved this via nginx and subdomain for backend.
My nginx.conf:
My nginx in docker container:
My nginx Dockerfile:
Try to include this in a place where you define "app".
This adds CORS middleware to allow origins and requests to come.