Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| engineering:computer_science:docker:application_guides:traefik_docker_https_ssl_for_containers [2024/08/16 15:05] – removed - external edit (Unknown date) 127.0.0.1 | engineering:computer_science:docker:application_guides:traefik_docker_https_ssl_for_containers [2024/08/16 16:14] (current) – ↷ Links adapted because of a move operation 47.128.47.22 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Using " | ||
| + | |||
| + | ===== Important Note : ===== | ||
| + | |||
| + | This is an alternative method to [[engineering: | ||
| + | |||
| + | ===== Purpose: ===== | ||
| + | |||
| + | The purpose of using Traefik are: | ||
| + | |||
| + | * Prevent having to restart the [[engineering: | ||
| + | * Ease of Escalability - We will be able to scale our infrastructure faster, since we don't have to manage HTTPS Certificates for every subdomain | ||
| + | * Keep the services so that, they are individuals service, but working though a central distributor. This could also be done with a [[engineering: | ||
| + | |||
| + | ===== Create the Folder and Config Files ===== | ||
| + | |||
| + | * Change the Path under " | ||
| + | |||
| + | <code bash> | ||
| + | #!/bin/bash | ||
| + | STORAGE_PATH="/ | ||
| + | mkdir -p " | ||
| + | touch " | ||
| + | chmod 600 " | ||
| + | touch " | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Deploy the Traefik configuration ===== | ||
| + | |||
| + | * Change " | ||
| + | |||
| + | <code bash> | ||
| + | nano traefik.yml | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | api: | ||
| + | dashboard: true | ||
| + | |||
| + | entryPoints: | ||
| + | http: | ||
| + | address: ": | ||
| + | https: | ||
| + | address: ": | ||
| + | |||
| + | providers: | ||
| + | docker: | ||
| + | endpoint: " | ||
| + | exposedByDefault: | ||
| + | |||
| + | certificatesResolvers: | ||
| + | http: | ||
| + | acme: | ||
| + | email: email@example.com | ||
| + | storage: acme.json | ||
| + | httpChallenge: | ||
| + | entryPoint: http | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Create the traefik docker-compose.yml ===== | ||
| + | |||
| + | * Change the " | ||
| + | * Create a USER: | ||
| + | |||
| + | <code bash> | ||
| + | echo $(htpasswd -nb < | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | <code bash> | ||
| + | version: ' | ||
| + | |||
| + | services: | ||
| + | traefik: | ||
| + | image: traefik: | ||
| + | container_name: | ||
| + | restart: unless-stopped | ||
| + | security_opt: | ||
| + | - no-new-privileges: | ||
| + | networks: | ||
| + | - proxy | ||
| + | ports: | ||
| + | - 80:80 | ||
| + | - 443:443 | ||
| + | volumes: | ||
| + | - / | ||
| + | - / | ||
| + | - ./ | ||
| + | - ./ | ||
| + | labels: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | |||
| + | networks: | ||
| + | proxy: | ||
| + | external: true | ||
| + | " | ||
| + | - " | ||
| + | - " | ||
| + | |||
| + | networks: | ||
| + | proxy: | ||
| + | external: true | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | ===== Adding Services to Traefik ===== | ||
| + | |||
| + | Start the traefik container - docker-compose up -d | ||
| + | |||
| + | Change your docker-compose.yml from other services to be available via Traefik. | ||
| + | |||
| + | As example, here is my docker-compose.yml for DokuWiki before and after Traefik. | ||
| + | |||
| + | **Before** | ||
| + | |||
| + | <code yaml> | ||
| + | version: ' | ||
| + | |||
| + | volumes: | ||
| + | dokuwiki_data: | ||
| + | external: true | ||
| + | dokuwiki_conf: | ||
| + | external: true | ||
| + | dokuwiki_lib-plugins: | ||
| + | external: true | ||
| + | dokuwiki_lib-tpl: | ||
| + | external: true | ||
| + | dokuwiki_logs: | ||
| + | external: true | ||
| + | |||
| + | services: | ||
| + | dokuwiki: | ||
| + | image: ' | ||
| + | container_name: | ||
| + | ports: | ||
| + | - ' | ||
| + | volumes: | ||
| + | - dokuwiki_data:/ | ||
| + | - dokuwiki_conf:/ | ||
| + | - dokuwiki_lib-plugins:/ | ||
| + | - dokuwiki_lib-tpl:/ | ||
| + | - dokuwiki_logs:/ | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | **After** | ||
| + | |||
| + | * You can uncomment the " | ||
| + | * Add the " | ||
| + | * Don't forget to change the " | ||
| + | * Don't forget to change the " | ||
| + | * For complex services (for example Wordpress + MySQL), add an extra network, for eg. " | ||
| + | |||
| + | <code yaml> | ||
| + | version: ' | ||
| + | |||
| + | volumes: | ||
| + | dokuwiki_data: | ||
| + | external: true | ||
| + | dokuwiki_conf: | ||
| + | external: true | ||
| + | dokuwiki_lib-plugins: | ||
| + | external: true | ||
| + | dokuwiki_lib-tpl: | ||
| + | external: true | ||
| + | dokuwiki_logs: | ||
| + | external: true | ||
| + | |||
| + | services: | ||
| + | dokuwiki: | ||
| + | image: ' | ||
| + | container_name: | ||
| + | restart: unless-stopped | ||
| + | networks: | ||
| + | - proxy | ||
| + | #ports: | ||
| + | # - ' | ||
| + | volumes: | ||
| + | - dokuwiki_data:/ | ||
| + | - dokuwiki_conf:/ | ||
| + | - dokuwiki_lib-plugins:/ | ||
| + | - dokuwiki_lib-tpl:/ | ||
| + | - dokuwiki_logs:/ | ||
| + | labels: | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | - " | ||
| + | |||
| + | networks: | ||
| + | | ||
| + | | ||
| + | |||
| + | |||
| + | </ | ||
| + | |||
| + | After starting the service, it should now be available. | ||
| + | |||