Wirecloud / docker-wirecloud

🐳 Docker Official Image packaging for WireCloud https://conwet.fi.upm.es/wirecloud
Other
8 stars 15 forks source link

502 Bad Gateway nginx/1.15.8 #22

Closed arilwan closed 5 years ago

arilwan commented 5 years ago

Want to work with Wirecloud, unfortunately, nginx failed to load, with following error: 502 Bad Gateway nginx/1.15.8

I can confirm nginx, wirecloud and postgres all running:

$ docker container ls
CONTAINER ID        IMAGE                                   COMMAND                  CREATED             STATUS              PORTS                                                      NAMES
190b97ea946b        nginx                                   "nginx -g 'daemon of…"   10 minutes ago      Up 10 minutes       0.0.0.0:80->80/tcp                                         fiware-nginx
200859165ab6        fiware/wirecloud                        "/docker-entrypoint.…"   10 minutes ago      Up 10 minutes       8000/tcp                                                   fiware-wirecloud
6f7b5c7705ca        postgres:latest                         "docker-entrypoint.s…"   10 minutes ago      Up 10 minutes       0.0.0.0:5432->5432/tcp                                     fiware-postgres
c8f0d820fec9        elasticsearch:2.4                       "/docker-entrypoint.…"   10 minutes ago      Up 10 minutes       9200/tcp, 9300/tcp                                         fiware-elasticsearch
79be28950329        memcached:1                             "docker-entrypoint.s…"   10 minutes ago      Up 10 minutes       11211/tcp                                                  fiware-memcached

Docker compose:

version: "3.1"

services:

  mongo:
    image: mongo:3.6
    hostname: mongo
    container_name: fiware-mongo
    ports:
      - "27017:27017"
    networks:
      - default
    command: --smallfiles
  orion:
    image: fiware/orion
    hostname: orion
    container_name: fiware-orion
    depends_on:
      - mongo
    networks:
      - default
    ports:
      - "1026:1026"
    expose:
      - "1026"
    command: -dbhost mongo -logLevel DEBUG
  lightweightm2m-iotagent:
    image: telefonicaiot/lightweightm2m-iotagent
    hostname: idas
    container_name: fiware-iotagent
    depends_on:
      - mongo
    networks:
      - default
    ports:
      - "4041:4041"
      - "5684:5684/udp"
    expose:
      - "4041"
      - "5684"
    environment:
      - "IOTA_CB_HOST=orion"
      - "IOTA_CB_PORT=1026"
      - "IOTA_NORTH_PORT=4041"
      - "IOTA_REGISTRY_TYPE=mongodb"
      - "IOTA_LOG_LEVEL=DEBUG"
      - "IOTA_TIMESTAMP=true"
      - "IOTA_MONGO_HOST=mongo"
      - "IOTA_MONGO_PORT=27017"
      - "IOTA_MONGO_DB=lwm2miotagent"
      - "IOTA_HTTP_PORT=5684"
      - "IOTA_PROVIDER_URL=http://lightweightm2m-iotagent:4041"
  cygnus:
    image: fiware/cygnus-ngsi:latest
    hostname: cygnus
    container_name: fiware-cygnus
    depends_on:
      - mongo
    networks:
      - default
    expose:
      - "5080"
    ports:
      - "5050:5050"
      - "5080:5080"
    environment:
      - "CYGNUS_MONGO_HOSTS=mongo:27017"
      - "CGYNUS_LOG_LEVEL_=DEBUG"
      - "CYGNUS_SERVICE_PORT=5050"
      - "CYGNUS_API_PORT=5080"
  nginx:
    restart: always
    image: nginx
    container_name: fiware-nginx
    ports:
      - 80:80
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./wirecloud-static:/var/www/static:ro
    depends_on:
      - wirecloud
  postgres:
    restart: always
    image: postgres:latest
    container_name: fiware-postgres
    ports:
      - "5432:5432"
    expose:
      - "5432"
    environment:
      - POSTGRES_PASSWORD=postgres
    volumes:
      - ./postgres-data:/var/lib/postgresql/data
  elasticsearch:
    restart: always
    image: elasticsearch:2.4
    container_name: fiware-elasticsearch
    volumes:
      - ./elasticsearch-data:/usr/share/elasticsearch/data
    command: elasticsearch -Des.index.max_result_window=50000
  memcached:
    restart: always
    image: memcached:1
    container_name: fiware-memcached
    command: memcached -m 2048m
  wirecloud:
    restart: always
    container_name: fiware-wirecloud
    image: fiware/wirecloud
    depends_on:
      - postgres
      - elasticsearch
      - memcached
    environment:
      - DEBUG=False
    # - DEFAULT_THEME=wirecloud.defaulttheme
      - DB_HOST=postgres
      - DB_PASSWORD=postgres   
      - FORWARDED_ALLOW_IPS=*
      - ELASTICSEARCH2_URL=http://elasticsearch:9200/
      - MEMCACHED_LOCATION=memcached:11211
     # Uncomment the following environment variables to enable IDM integration
     #- FIWARE_IDM_SERVER=${FIWARE_IDM_SERVER}
     #- SOCIAL_AUTH_FIWARE_KEY=${SOCIAL_AUTH_FIWARE_KEY}
     #- SOCIAL_AUTH_FIWARE_SECRET=${SOCIAL_AUTH_FIWARE_SECRET}
    volumes:
      - ./wirecloud-data:/opt/wirecloud_instance/data
      - ./wirecloud-static:/var/www/static

nginx.conf file:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    server {

        listen 80;
        server_name example.org;
        client_max_body_size 20M;
        charset utf-8;

        location /static {
            alias /var/www/static;
        }

        location / {
            proxy_pass http://wirecloud: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;
        }

    }
}
aarranz commented 5 years ago

The error 502 returned by nginx means that the WireCloud (fiware-wirecloud) container is not working as expected. Please check or post the logs for that container.

Configuration itself seems correct for me, although I have not tested it.

arilwan commented 5 years ago

@aarranz Yes, it is working now, I will go ahead to close this issue. Meanwhile I'm not sure how/where to set-up the credentials to the login page, should this be set in docker-compose.yml? screenshot 2019-01-27 at 11 17 46

aarranz commented 5 years ago

No user is created by default, so you have to create one using the createsuperuser command or configure an IdM server.

arilwan commented 5 years ago

I get it, many thanks. Closing...