Forgive me if I am asking a stupid question, but I am building a server where I will host multiple Flask websites Docker Container using Nginx Docker. My question now is: is it better to have one main nginx docker container and then host all my Websites Docker containers on it or have an Nginx docker container for each application with docker compose?
I want to know in terms of resource handling and efficiency which one is better to go for ?
@Jacob Following your answer, i am trying to setup something like this
docker-compose.yml:
version: "3.8" services: portfolix: container_name: portfolix image: mervin16/portfolix:dev env_file: - config_local.env expose: - 8086 restart: always networks: - sky_net mes: container_name: mes image: mervin16/mes:dev networks: - sky_net expose: - 8085 restart: always nginx: build: ./nginx container_name: nginx ports: - "8085:85" - "8086:86" restart: always networks: - sky_net networks: sky_net: name: sky_network driver: bridge Now each website is available on localhost:8085 and localhost:8086
I am then using a reverse proxy on Nginx (not docker but the one installed on my server) to redirect traffic to my domain name:
server { server_name mes.th3pl4gu3.com; location / { access_log /var/log/nginx/mes/access_mes.log; error_log /var/log/nginx/mes/error_mes.log; proxy_pass http://localhost:8081; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/mes.th3pl4gu3.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/mes.th3pl4gu3.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server { if ($host = mes.th3pl4gu3.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name mes.th3pl4gu3.com; return 404; # managed by Certbot }