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?

1
  • Tell if i missing some part... you are exposing 8080 into nginx container, but your nginx listen over port 80. Commented Jun 20, 2017 at 16:47

1 Answer 1

1

Try changing the port mapping for nginx service as below:

 ports:
  - "8880:80"

or make nginx listen on port 8080.

Sign up to request clarification or add additional context in comments.

7 Comments

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.
@AndrewGraham-Yooll Could you update your question with your current configuration?
@CélineAussourd Done.
@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")
@AndrewGraham-Yooll Concerning the WORKER TIMEOUT errors, that's an other issue. See: stackoverflow.com/questions/10855197/…
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.