这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/networking/proxies/traefik.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ dokku traefik:stop

The Traefik container will be stopped and removed from the system. If the container is not running, this command will do nothing.

### Changing the Traefik entrypoint names

When you use a self-hosted Traefik instance, your entrypoint names might be different from the default `http` and `https`

Use `traefik:set` to set both `http-entry-point` and `https-entry-point` to custom values

```shell
dokku traefik:set --global http-entry-point web
dokku traefik:set --global https-entry-point websecure
```

### Showing the Traefik compose config

For debugging purposes, it may be useful to show the Traefik compose config. This can be achieved via the `traefik:show-config` command.
Expand Down
2 changes: 2 additions & 0 deletions plugins/traefik-vhosts/command-functions
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ cmd-traefik-report-single() {
"--traefik-letsencrypt-email: $(fn-traefik-letsencrypt-email)"
"--traefik-letsencrypt-server: $(fn-traefik-letsencrypt-server)"
"--traefik-log-level: $(fn-traefik-log-level)"
"--traefik-http-entry-point: $(fn-traefik-http-entry-point)"
"--traefik-https-entry-point: $(fn-traefik-https-entry-point)"
)

if [[ -z "$INFO_FLAG" ]]; then
Expand Down
4 changes: 2 additions & 2 deletions plugins/traefik-vhosts/docker-args-process-deploy
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
fi

output="$output --label traefik.http.services.$APP-$PROC_TYPE-http.loadbalancer.server.port=$proxy_container_http_port"
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.entrypoints=http"
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.entrypoints=$(fn-traefik-http-entry-point)"
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-http.service=$APP-$PROC_TYPE-http"
if [[ -n "$traefik_domains" ]]; then
output="$output --label \"traefik.http.routers.$APP-$PROC_TYPE-http.rule=Host(\\\`$traefik_domains\\\`)\""
Expand All @@ -111,7 +111,7 @@ trigger-traefik-vhosts-docker-args-process-deploy() {
fi

output="$output --label traefik.http.services.$APP-$PROC_TYPE-https.loadbalancer.server.port=$proxy_container_https_port"
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=https"
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.entrypoints=$(fn-traefik-https-entry-point)"
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.service=$APP-$PROC_TYPE-https"
output="$output --label traefik.http.routers.$APP-$PROC_TYPE-https.tls.certresolver=leresolver"
if [[ -n "$traefik_domains" ]]; then
Expand Down
8 changes: 8 additions & 0 deletions plugins/traefik-vhosts/internal-functions
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ fn-traefik-log-level() {
log_level="$(fn-plugin-property-get-default "traefik" "--global" "log-level" "ERROR")"
echo "${log_level^^}"
}

fn-traefik-http-entry-point() {
fn-plugin-property-get-default "traefik" "--global" "http-entry-point" "http"
}

fn-traefik-https-entry-point() {
fn-plugin-property-get-default "traefik" "--global" "https-entry-point" "https"
}
4 changes: 2 additions & 2 deletions plugins/traefik-vhosts/subcommands/set
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ cmd-traefik-set() {
declare cmd="traefik:set"
[[ "$1" == "$cmd" ]] && shift 1
declare APP="$1" KEY="$2" VALUE="$3"
local VALID_KEYS=("api-enabled" "api-vhost" "dashboard-enabled" "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level")
local GLOBAL_KEYS=("api-enabled" "api-vhost" "dashboard"-enabled "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level")
local VALID_KEYS=("api-enabled" "api-vhost" "dashboard-enabled" "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level" "http-entry-point" "https-entry-point")
local GLOBAL_KEYS=("api-enabled" "api-vhost" "dashboard-enabled" "basic-auth-username" "basic-auth-password" "image" "letsencrypt-email" "letsencrypt-server" "log-level" "http-entry-point" "https-entry-point")

[[ -z "$KEY" ]] && dokku_log_fail "No key specified"

Expand Down
62 changes: 62 additions & 0 deletions tests/unit/traefik.bats
Original file line number Diff line number Diff line change
Expand Up @@ -237,3 +237,65 @@ teardown() {
assert_success
assert_line ' - "traefik.http.routers.api.middlewares=auth"'
}

@test "(traefik) change traefik entry point http" {
run /bin/bash -c "dokku builder-herokuish:set $TEST_APP allowed true"
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "dokku proxy:set $TEST_APP traefik"
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "dokku traefik:set --global http-entry-point web"
echo "output: $output"
echo "status: $status"
assert_success

run deploy_app
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"traefik.http.routers.$TEST_APP-web-http.entrypoints\" }}'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "web"

}

@test "(traefik) change traefik entry point https" {
run /bin/bash -c "dokku builder-herokuish:set $TEST_APP allowed true"
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "dokku proxy:set $TEST_APP traefik"
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "dokku traefik:set --global letsencrypt-email test@example.com"
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "dokku traefik:set --global https-entry-point websecure"
echo "output: $output"
echo "status: $status"
assert_success

run deploy_app
echo "output: $output"
echo "status: $status"
assert_success

run /bin/bash -c "docker inspect $TEST_APP.web.1 --format '{{ index .Config.Labels \"traefik.http.routers.$TEST_APP-web-https.entrypoints\" }}'"
echo "output: $output"
echo "status: $status"
assert_success
assert_output "websecure"
}