Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide working nginx reverse proxy config example #93

Open
jantonz opened this issue Aug 4, 2021 · 0 comments
Open

Provide working nginx reverse proxy config example #93

jantonz opened this issue Aug 4, 2021 · 0 comments

Comments

@jantonz
Copy link

jantonz commented Aug 4, 2021

FYI: I think it's related to your card https://github.com/koel/docker/projects/1#card-31191171

Using a reverse proxy is a common way of accessing dockerized services outside your local network. Some typical reverse proxy docker images include Traefik and SWAG. The latter, SWAG, is extremely easy to use and I do have a working configuration for Koel (in the case of using Linuxserver's latest SWAG docker container, this config should be placed by default in ~/.config/appdata/swag/nginx/proxy-confs/koel.subdomain.conf):

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name koel.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {
    
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_app koel;
        set $upstream_port 8090;
        set $upstream_proto http;
        proxy_pass $upstream_proto://<your_server_ip>:$upstream_port;
    }

    location ~ (/koel)?/api {
        include /config/nginx/proxy.conf;
        resolver 127.0.0.11 valid=30s;
        set $upstream_app koel;
        set $upstream_port 8090;
        set $upstream_proto http;
        proxy_pass $upstream_proto://<your_server_ip>:$upstream_port;

   }
}

For this config to work, however, the environment variable FORCE_HTTPS=true needs to be added in the compose file for koel; otherwise, a blank page is served (no error, only a blank, uninformative page). For completion, this is an extract of the docker-compose.yml used for these services: SWAG and Koel:

version: "3.7"

services:
  koel:
    image: hyzual/koel
    container_name: koel
    depends_on:
      - database
    ports:
      - 8090:80
    networks:
      - proxy  
    environment:
      - FORCE_HTTPS=true
      - DB_CONNECTION=pgsql
      - DB_HOST=database
      - DB_USERNAME=koel
      - DB_PASSWORD=<koel_password>
      - DB_DATABASE=koel
    volumes:
      - music:/music
      - covers:/var/www/html/public/img/covers
      - search_index:/var/www/html/storage/search-indexes

  database:
    image: postgres:13
    container_name: koel-db
    volumes:
      - db:/var/lib/postgresql/data'
    environment:
      - POSTGRES_DB=koel
      - POSTGRES_USER=koel
      - POSTGRES_PASSWORD=koel_password_0987

  swag:
    image: ghcr.io/linuxserver/swag
    hostname: ${DOCKERHOSTNAME}
    ports:
      - ${SWAG_PORT_443}:443
      - ${SWAG_PORT_80}:80
    cap_add:
      - NET_ADMIN
    networks:
      - proxy
    container_name: swag
    environment:
      - DNSPLUGIN=${SWAG_DNSPLUGIN}
      - DUCKDNSTOKEN=${SWAG_DUCKDNSTOKEN}
      - EMAIL=${SWAG_EMAIL}
      - EXTRA_DOMAINS=${SWAG_EXTRA_DOMAINS}
      - ONLY_SUBDOMAINS=${SWAG_ONLY_SUBDOMAINS}
      - PGID=${PGID}
      - PUID=${PUID}
      - SUBDOMAINS=${SWAG_SUBDOMAINS}
      - TZ=${TZ}
      - URL=${SWAG_URL}
      - VALIDATION=${SWAG_VALIDATION}
      - MAXMINDDB_LICENSE_KEY=${SWAG_MAXMINDDB_LICENSE_KEY}
    logging:
      driver: json-file
      options:
        max-file: ${DOCKERLOGGING_MAXFILE}
        max-size: ${DOCKERLOGGING_MAXSIZE}
    restart: ${SWAG_RESTART}
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${DOCKERCONFDIR}/swag:/config
      - ${DOCKERSTORAGEDIR}:/storage


networks:
  proxy:
    external: true
@jantonz jantonz changed the title Provide working nginx reverse proxy config example Provide working nginx reverse proxy config example for dockerized koel Aug 4, 2021
@jantonz jantonz changed the title Provide working nginx reverse proxy config example for dockerized koel Provide working nginx reverse proxy config example Aug 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant