D
D
Dmitry Filyushin2019-11-15 07:45:38
Nginx
Dmitry Filyushin, 2019-11-15 07:45:38

How to make Docker friends with Flask and external nginx?

Good afternoon
Please let me know. There is a Flask application with statics (Gunicorn). I want to dockerize it. However, on the server where I plan to deploy, nginx is already installed. How can you befriend them?
The forums advise creating a separate image for nginx + app + database. But what if part of the system is already functioning?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2019-11-15
@Filyushin

Set a new location in nginx and proxy requests to your container.
Simplified like this:

location /new/app/path/ {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://localhost:8000;
}

* Specify your port and path
If multiple container instances are running:
upstream backend {
    server backend1.example.com       weight=5;
    server backend2.example.com:8080;
    server unix:/tmp/backend3;

    server backup1.example.com:8080   backup;
    server backup2.example.com:8080   backup;
}

server {
    location / {
        proxy_pass http://backend;
    }
}

nginx.org/ru/docs/http/ngx_http_upstream_module.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question