E
E
Egor Sh2016-03-18 13:08:51
Nginx
Egor Sh, 2016-03-18 13:08:51

How to configure Docker to work nginx reverse proxy server with nginx http server?

Good afternoon! I'm trying to set up docker on my server and it doesn't quite work out. I have several containers:
1. Ubuntu container (which other containers will use)
2. Container of the site itself (Angular2) plus nginx, which should give the site a reverse proxy to the nginx container
3. nginx_reverse_proxy container (Will take the site from container number 2 and give the site to the user at this url - site.queryme.ru, if the user goes to queryme.ru without a prefix, then he will be given the usual index.html stub.To
build all the containers, I use docker-compose.So
, docker-compose starts normally all containers, and there is not a single error, when I go to the site at queryme.ru, then the stub is correctly given if I already go to
site.queryme.ru then the site does not load and there is nothing in the logs (I suffered with the settings, but nothing happened. I posted the sources on github, you can see the configs there, I would be grateful if you could help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mureevms, 2016-03-18
. @EgorkZe

It's not entirely clear, you are proxying the site with nginx

server_name site.query.ru;
на
proxy_pass http://site;

That being said, I don't see this name in the docker-compose build rules. The container must either be given the name site or be proxyed to the container with Angular2, but again its name is not declared. In addition, port 8081 is exposed in the query container, and proxy_pass is set to 80.
And I also do not see the announcement of the docker local network. Try doing something like this:
networks:
  mynetwork:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 10.10.10.0/24
          ip_range: 10.10.0.0/24
          gateway: 10.10.10.1

services:
  # Контейнер с проксирующим nginx
  nginx:
    container_name: nginx
    build: images/nginx
    networks:
      - mynetwork

  # Контейнер с сайтом
  site:
    container_name: site
    build: images/site
    networks:
      - mynetwork

Ports and volumes intentionally do not write, add yourself.
And it's not at all clear why you need two nginx? What is the essence of proxying? (or maybe I just didn't get the config)

A
Alexander Sharihin, 2016-03-18
@Pinsky

Site config:

server {
 listen 80;
 server_name tender.local;

 location / {
  proxy_pass http://tender:80/;
 }
}

And in docker compose:
frontend:
 build: ./frontend
 volumes: 
 - ./frontend/conf.d:/etc/nginx/conf.d
 - ./frontend/log:/var/log/nginx
 ports:
 - "80:80"
 links:
 - tender

tender:
 build: ./tender
 volumes:
 - ./tender/html:/var/www/html
 - ./tender/log:/var/log/
 links:
 - mysql:dev-mysql

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question