SteveLTN / https-portal

A fully automated HTTPS server powered by Nginx, Let's Encrypt and Docker.
MIT License
4.46k stars 295 forks source link

Configure https-portal and Streamlit - web app #332

Open dan-adi opened 1 year ago

dan-adi commented 1 year ago

Hello, I am having trouble configuring https-portal to work with a Streamlit web app deployed with docker. This is my attempt at a docker-compose.yaml:

version: '3'
services:
  https-portal:
    image: steveltn/https-portal:1
    ports:
      - '80:80'
      - '443:443'
    links:
      - streamlit_app
    restart: always
    environment:
      WEBSOCKET: 'true'
      DOMAINS: 'http://example.go.ro/ -> http://streamlit_app:8501'
      STAGE: production # mantenha em staging até o total funcionamento
    volumes:
      - https-portal-data:/var/lib/https-portal

  streamlit_app:
    build:
      dockerfile: ./Dockerfile
      context: ./ 
    volumes:
      - .:/ETCWebApp
    ports:
      - 8501:8501
    restart: always

On my router I have the external ports 80,443 forwarded to internal 8501 port. Using the docker-compose up, I get no errors, but I can only access my webapp on HTTP not HTTPS. Any ideas how to make it work? Thank you

dan-adi commented 1 year ago

This is the error it gives:

Failed to sign clearskies.go.ro.
https-portal_1   | Make sure your DNS is configured correctly and is propagated to this host
https-portal_1   | machine. Sometimes that takes a while.

Any idea how to solve it?

gerold-penz commented 1 year ago

Hi!

1.) I think, your docker-compose.yaml should look like this:

services:

  streamlit_app:
    build:
      dockerfile: ./Dockerfile
      context: ./ 
    volumes:
      - .:/ETCWebApp
    restart: unless-stopped

  https-portal:
    image: steveltn/https-portal:1.22
    depends_on:
      - streamlit_app
    ports:
      - '80:80'
      - '443:443'
    restart: unless-stopped
    environment:
      WEBSOCKET: 'true'
      DOMAINS: 'example.go.ro -> streamlit_app:8501'
      STAGE: production # mantenha em staging até o total funcionamento
    volumes:
      - https-portal-data:/var/lib/https-portal

2.) Your router must forward the ports 80 and 443 to your computer, directly. Not the Port 8501.

Router 80 --> Computer 80
Router 443 --> Computer 443

Maybe it helps.

dan-adi commented 1 year ago

Hi!

1.) I think, your docker-compose.yaml should look like this:

services:

  streamlit_app:
    build:
      dockerfile: ./Dockerfile
      context: ./ 
    volumes:
      - .:/ETCWebApp
    restart: unless-stopped

  https-portal:
    image: steveltn/https-portal:1.22
    depends_on:
      - streamlit_app
    ports:
      - '80:80'
      - '443:443'
    restart: unless-stopped
    environment:
      WEBSOCKET: 'true'
      DOMAINS: 'example.go.ro -> streamlit_app:8501'
      STAGE: production # mantenha em staging até o total funcionamento
    volumes:
      - https-portal-data:/var/lib/https-portal

2.) Your router must forward the ports 80 and 443 to your computer, directly. Not the Port 8501.

Router 80 --> Computer 80
Router 443 --> Computer 443

Maybe it helps.

Thank you, it works now.! The yaml file looks like this:

services:
  streamlit_app:
    build:
      dockerfile: ./Dockerfile
      context: ./ 
    volumes:
      - .:/ETCWebApp
    ports:
      - 8501:8501
    restart: unless-stopped

  https-portal:
    image: steveltn/https-portal:1.22
    depends_on:
      - streamlit_app
    ports:
      - '80:80'
      - '443:443'
    restart: unless-stopped
    environment:
      WEBSOCKET: 'true'
      DOMAINS: 'example.go.ro -> streamlit_app:8501'

I also made the router changes you provided.