0

So I have banging my head on this issue for the past hours, and I have got a docker-compose.yml file

version: '2'

services:
  web:
    restart: always
    build: ./web_app
    expose:
      - "8000"
    ports:
      - "8000:8000"
    volumes:
      - ./web_app:/data/web
    command: /usr/local/bin/gunicorn web_interface:app -w 4 -t 90 --log-level=debug -b 0.0.0.0:8000 --reload
    depends_on:
      - postgres

  nginx:
    restart: always
    build: ./nginx
    ports:
     - "8080:80"
    volumes_from:
      - web
    depends_on:
      - web

  postgres:
    restart: always
    image: postgres:latest
    volumes_from:
      - data
    volumes:
      - ./postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
      - ./backups/postgresql:/backup
    expose:
      - "5432"

  data:
    restart: always
    image: alpine
    volumes:
      - /var/lib/postgresql
    tty: true

However, when I docker-compose up and then navigate to localhost:8880, I get nothing served. Is like the nginx server is not accepting connections through the localhost.

nginx.conf

server {

    listen 80;
    server_name localhost;
    charset utf-8;

    location /static/ {
        alias /data/web/crm/web_interface;
    }

    location = /favicon.ico {
        alias /data/web/crm/web_interface/static/favicon.ico;
    }

    location / {
        proxy_pass http://web:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

}

nginx/Dockerfile

FROM nginx:latest

RUN rm /etc/nginx/conf.d/default.conf

COPY ./nginx.conf /etc/nginx/conf.d/nginx.conf 

And this is whats in my terminal:terminal shot

I have been following this tutorial fairly closely, but it cant seem to serve the Flask App that I have created. Any ideas?

Andrew Graham-Yooll
  • 2,148
  • 4
  • 24
  • 49
  • Tell if i missing some part... you are exposing 8080 into nginx container, but your nginx listen over port 80. – German Jun 20 '17 at 16:47

1 Answers1

1

Try changing the port mapping for nginx service as below:

 ports:
  - "8880:80"

or make nginx listen on port 8080.

Qasim Sarfraz
  • 5,822
  • 2
  • 20
  • 26
  • Actually on second examination, and Im not sure if it because of your or @German's advice, when i nav to localhost:8080 then screen loads for a while and then returns a 504 nginx error. So this is a move in a positive direction. – Andrew Graham-Yooll Jun 21 '17 at 07:43
  • @AndrewGraham-Yooll Could you update your question with your current configuration? – Céline Aussourd Jun 21 '17 at 13:19
  • @CélineAussourd Done. – Andrew Graham-Yooll Jun 21 '17 at 13:54
  • 1
    @AndrewGraham-Yooll In your nginx configuration you are listening to port 80 so you should expose the port 80 (not 8080) in the docker-compose in the nginx section: `- "80:80"` (instead of `- "8080:80"`) – Céline Aussourd Jun 21 '17 at 14:00
  • @AndrewGraham-Yooll Concerning the WORKER TIMEOUT errors, that's an other issue. See: https://stackoverflow.com/questions/10855197/gunicorn-worker-timeout-error – Céline Aussourd Jun 21 '17 at 14:06
  • Thanks @CélineAussourd, I changed it back like you mentioned, but Im curious as to why it matters. It doesn't seem to make any difference in my application serving. – Andrew Graham-Yooll Jun 21 '17 at 14:29
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/147283/discussion-between-celine-aussourd-and-andrew-graham-yooll). – Céline Aussourd Jun 21 '17 at 14:32