Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

379
Views
Configure Nginx with two docker-compose containers (Flask and Django)

I am trying to expose two different address used like APIs. One in Django and the other one in Flask, they are Docker-compose containers.

I need configure Nginx for expose the two containers in two different subdomains.

It is my Nginx.conf:

user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
 worker_connections  1024;  ## Default: 1024, increase if you have lots of clients
 }    

http {
  include       /etc/nginx/mime.types;
  # fallback in case we can't determine a type
  default_type  application/octet-stream;

 log_format  main  '$remote_addr - $remote_user [$time_local] 
"$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

upstream app {
 server django:5000;
}

upstream app_server {
 server flask:5090;
}

server {
 listen 5090;
 location / {
    proxy_pass http://app_server;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Scheme $scheme;
  }
}

server {
 listen 5000;
 location / {
    proxy_pass http://app;
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Scheme $scheme;
 }
 }

}

And my production.yml

Nginx:
  build: ./compose/production/nginx
  image: *image
  ports:
    - 80:80
  depends_on:
    - flask
    - django

My containers are all up.

enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I use proxy_pass:

server {
    listen <port>;
    location / {
        proxy_pass http://<container-host-name>:<port>;
        proxy_set_header Host $http_host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Scheme $scheme;
    }
}

You nginx container connected only with 80 port on machine and 80 port on container, but you nginx server listen 5000 and 5090 ports :)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!