sosedoff / pgweb

Cross-platform client for PostgreSQL databases
https://sosedoff.github.io/pgweb
MIT License
8.63k stars 732 forks source link

Getting "bad gateway" #367

Closed JasCodes closed 6 years ago

JasCodes commented 6 years ago

Error "Bad Gateway" Following is my docker setup

Traefic Reverse proxy

version: "3.2"
Reverse Proxy
services:
  traefik:
    container_name: traefik
    restart: unless-stopped
    image: traefik:1.6.4
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/mnt/traefik:/etc/traefik/"
    command: traefik --docker --docker.domain=docker.localhost --logLevel=INFO --docker.watch --acme --acme.onhostrule --acme.httpchallenge.entrypoint=http --acme.storage=/etc/traefik/acme/acme.json --acme.email=dev@jas.bio --acme.entryPoint=https --entryPoints='Name:http Address::80 Redirect.EntryPoint:https' --entryPoints='Name:https Address::443 TLS' --defaultentrypoints=http,https
    #command: traefik --web --docker --docker.domain=docker.localhost --loglevel=INFO
    networks: 
      - gateway

networks:
  gateway:
    driver: bridge

pgweb

  pgweb:
    container_name: pgweb
    image: sosedoff/pgweb
    restart: unless-stopped
    networks: 
      - traefik_gateway
    labels:
      - "traefik.enable=true"
      - "traefik.frontend.rule=Host:db.abc.com"
      - "traefik.acme.domains=db.abc.com"
      - "traefik.port=8081"
    command: pgweb --host postgres.abc.com --user abc --pass abc --db abc --ssl disable

Lemme know if you have further questions

Thx

sosedoff commented 6 years ago

You need to bind to 0.0.0.0, pgweb is listening on localhost only by default.

On Jun 17, 2018, at 1:26 PM, Jaspreet Singh notifications@github.com wrote:

Error "Bad Gateway" Following is my docker setup

Traefic Reverse proxy

version: "3.2" Reverse Proxy services: traefik: container_name: traefik restart: unless-stopped image: traefik:1.6.4 ports:

  • "80:80"
  • "443:443" volumes:
  • "/var/run/docker.sock:/var/run/docker.sock"
  • "/mnt/traefik:/etc/traefik/" command: traefik --docker --docker.domain=docker.localhost --logLevel=INFO --docker.watch --acme --acme.onhostrule --acme.httpchallenge.entrypoint=http --acme.storage=/etc/traefik/acme/acme.json --acme.email=dev@jas.bio --acme.entryPoint=https --entryPoints='Name:http Address::80 Redirect.EntryPoint:https' --entryPoints='Name:https Address::443 TLS' --defaultentrypoints=http,https

    command: traefik --web --docker --docker.domain=docker.localhost --loglevel=INFO

    networks:

  • gateway

networks: gateway: driver: bridge pgweb

pgweb: container_name: pgweb image: sosedoff/pgweb restart: unless-stopped networks:

  • traefik_gateway labels:
  • "traefik.enable=true"
  • "traefik.frontend.rule=Host:db.abc.com"
  • "traefik.acme.domains=db.abc.com"
  • "traefik.port=8081" command: pgweb --host postgres.abc.com --user abc --pass abc --db abc --ssl disable

Lemme know if you have further questions

Thx

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

JasCodes commented 6 years ago

Didn't work for me, but I am considering something weird might be with my reverse proxy; I am gonna stash this for later on my todo list to figure I out.

I will post here once I do, anyways thx for suggestion @sosedoff

sosedoff commented 6 years ago

@jas99 btw was that a traefik config or docker compose or something else? i was replying from email after looking at your sample config, which didnt really ring a bell.

JasCodes commented 6 years ago

@sosedoff Yup those are docker compose files, the traefik configuration is actually done with command in compose file itself.

    command: traefik --docker 
--docker.domain=docker.localhost 
--logLevel=INFO 
--docker.watch 
--acme 
--acme.onhostrule 
--acme.httpchallenge.entrypoint=http 
--acme.storage=/etc/traefik/acme/acme.json 
--acme.email=dev@jas.bio 
--acme.entryPoint=https 
--entryPoints='Name:http Address::80 Redirect.EntryPoint:https' 
--entryPoints='Name:https Address::443 TLS' 
--defaultentrypoints=http,https
sosedoff commented 6 years ago

@jas99 i was able to start both services with a modified config:

version: "3.2"

services:
  traefik:
    container_name: traefik
    restart: unless-stopped
    image: traefik:1.6.4
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
      - "/Users/sosedoff/docker/traefik:/etc/traefik/"
    #command: traefik --docker --docker.domain=docker.localhost --logLevel=INFO --docker.watch --acme --acme.onhostrule --acme.httpchallenge.entrypoint=http --acme.storage=/etc/traefik/acme/acme.json --acme.email=dev@jas.bio --acme.entryPoint=https --entryPoints='Name:http Address::80 Redirect.EntryPoint:https' --entryPoints='Name:https Address::443 TLS' --defaultentrypoints=http,https
    command: traefik --web --docker --docker.domain=docker.localhost --loglevel=INFO
    networks: 
      - gateway

  pgweb:
    container_name: pgweb
    image: sosedoff/pgweb
    restart: unless-stopped
    networks: 
      - gateway
    labels:
      - "traefik.enable=true"
      - "traefik.frontend.rule=Host:db.abc.com"
      - "traefik.acme.domains=db.abc.com"
      - "traefik.port=8081"
    command: pgweb --bind=0.0.0.0

networks:
  gateway:
    driver: bridge

Had to modify my /etc/hosts file with 127.0.0.1 db.abc.com.

I think main reason why you got 502 error is because pgweb did not start correctly due to invalid credentials / etc.

sosedoff commented 6 years ago

Im closing this issue since it has nothing to do with pgweb itself. To reiterate the issue: pgweb does work just fine with docker compose / kubernetes / swarm or any other container scheduler so if something does not work correctly make sure to double check the start arguments and network configuration. Also, feel free to ask any questions in this tread just in case.