M
M
maksam072020-12-02 14:46:40
Django
maksam07, 2020-12-02 14:46:40

How to set up a Docker-compose (Nginx, Django, Unicorn, Postgres) bundle so that different projects (not just django) are opened on different domains?

Good afternoon. I don't even know how difficult this question is. I have been looking for information for about 4 days, but all in vain.
Suppose I make a bunch according to the following instructions: https://testdriven.io/blog/dockerizing-django-with...
There is a repository on the github at the end.
But according to this instruction, to open the site, you must also enter the port after the domain name.
I went further:
1. Created a network: docker network create nginx-proxy
2. In a separate composition, I made a setting for Nginx so that it listens on ports 80 and 443 and config:

spoiler
5fc77d3b19e31644348804.png
5fc77d4442b70074102512.png

3. In the django project, I deleted the block with the enginx, because he is no longer needed.
spoiler
5fc77de08df42115321139.png

And I connected both compos with the network added at the first point.

And everything would be fine, now the site opens at localhost, but static images do not open for me, because enginx now does not know where to look for them. And now I can't figure out what to do next. How can an enginx in one container tell it to look for files in a specific folder in another container? Or am I doing it all wrong? During these few days, I probably climbed more than a few dozen pages, but I didn’t find any information about static files anywhere. I would be grateful if you poke your nose on how to correctly set the work of the engine for the work of different projects with different domains in different containers

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dooMoob, 2020-12-02
@dooMoob

1) in order not to enter a port after the domain, container nginx must be forced to listen on port 80, not 1337, or install another nginx on the host that would proxy certain requests to 1337
2) so that nginx can distribute static from another container, these containers should be total volume

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question