A
A
Andrew2020-02-27 14:24:55
DigitalOcean
Andrew, 2020-02-27 14:24:55

Deploy multiple apps on one droplet?

I'm immersed in the topic of deployment. I understand that you can have several applications on one droplet, each of which will be tied to its own domain. So far I don’t quite understand how it works - after all, there is only one external ip, the port too.

I assume this is all configurable in nginx? If so, does anyone have a good guide on setting it up? I watched enough lessons, I set it up myself about 10 times, but in my head it still remains magic and there is no understanding of what and why.

Can Nginx run in a container too? For two applications will there be one container with nginx or for each application? In general, I'm very noob in devops and I want to fix it)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2020-02-27
@AndrewRusinas

As an option:
nginx on the main system:

./nginx/sites-enabled/site1.conf:
{
  listen 80;
  server_name site1.example.org;

  location / {
     proxy_pass: http://127.0.0.1:8081;
 }

}

./nginx/sites-enabled/site2.conf:
{
  listen 80;
  server_name site2.example.org;

  location / {
     proxy_pass: http://127.0.0.1:8082;
 }
}

Containers for site1:
docker-compose.yml
nginx:
    volumes:
        - ./:/opt/site1-root
        - ./config/nginx:/etc/nginx/conf.d
    ports:
      - "0.0.0.0:8081:80"

./conf/nginx/site1_local.conf
{
   listen 80;
   
   local / {
       root  /opt/site1-root;
   }
}

Containers for site2:
docker-compose.yml
nginx:
    volumes:
        - ./:/opt/site2-root
        - ./config/nginx:/etc/nginx/conf.d
    ports:
      - "0.0.0.0:8082:80"

./conf/nginx/site2_local.conf
{
   listen 80;
   
   local / {
       root  /opt/site2-root;
   }
}

You can do without nginx in containers, and immediately bind the port to the main system nginx, you can make your own network - depending on what is running and how it is organized.

D
Dmitry, 2020-02-27
@q2digger

jwilder / nginx or some kind of traefic is put in front, which itself picks up the configuration from the environment variables of running containers and sorts virtual hosts into different containers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question