diff --git a/docs/content/operations/.markdownlint.json b/docs/content/operations/.markdownlint.json index 3cd5e9a07..e404a3618 100644 --- a/docs/content/operations/.markdownlint.json +++ b/docs/content/operations/.markdownlint.json @@ -1,4 +1,5 @@ { "extends": "../../.markdownlint.json", + "MD041": false, "MD046": false } diff --git a/docs/content/operations/api.md b/docs/content/operations/api.md index 636509f9e..b8a3c3391 100644 --- a/docs/content/operations/api.md +++ b/docs/content/operations/api.md @@ -43,63 +43,7 @@ api: {} And then define a routing configuration on Traefik itself with the [dynamic configuration](../getting-started/configuration-overview.md#the-dynamic-configuration): -```yaml tab="Docker" -# Dynamic Configuration -labels: - - "traefik.http.routers.api.rule=Host(`traefik.domain.com`)" - - "traefik.http.routers.api.service=api@internal" - - "traefik.http.routers.api.middlewares=auth" - - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" -``` - -```json tab="Marathon" -"labels": { - "traefik.http.routers.api.rule": "Host(`traefik.domain.com`)", - "traefik.http.routers.api.service": "api@internal", - "traefik.http.routers.api.middlewares": "auth", - "traefik.http.middlewares.auth.basicauth.users": "test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" -} -``` - -```yaml tab="Rancher" -# Dynamic Configuration -labels: - - "traefik.http.routers.api.rule=Host(`traefik.domain.com`)" - - "traefik.http.routers.api.service=api@internal" - - "traefik.http.routers.api.middlewares=auth" - - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" -``` - -```toml tab="File (TOML)" -# Dynamic Configuration -[http.routers.my-api] - rule = "Host(`traefik.domain.com`)" - service = "api@internal" - middlewares = ["auth"] - -[http.middlewares.auth.basicAuth] - users = [ - "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", - "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0", - ] -``` - -```yaml tab="File (YAML)" -# Dynamic Configuration -http: - routers: - api: - rule: Host(`traefik.domain.com`) - service: api@internal - middlewares: - - auth - middlewares: - auth: - basicAuth: - users: - - "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/" - - "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0" -``` +--8<-- "content/operations/include-api-examples.md" ??? warning "The router's [rule](../../routing/routers#rule) must catch requests for the URI path `/api`" Using an "Host" rule is recommended, by catching all the incoming traffic on this host domain to the API. diff --git a/docs/content/operations/dashboard.md b/docs/content/operations/dashboard.md index 166ffcb63..46fbb9775 100644 --- a/docs/content/operations/dashboard.md +++ b/docs/content/operations/dashboard.md @@ -60,8 +60,8 @@ api: --api.dashboard=true ``` -Then define a routing configuration on Traefik itself, -with a router attached to the service `api@internal` in the +Then define a routing configuration on Traefik itself, +with a router attached to the service `api@internal` in the [dynamic configuration](../getting-started/configuration-overview.md#the-dynamic-configuration), to allow defining: @@ -73,64 +73,7 @@ to allow defining: through Traefik itself (sometimes referred as "Traefik-ception"). ??? example "Dashboard Dynamic Configuration Examples" - - ```yaml tab="Docker" - # Dynamic Configuration - labels: - - "traefik.http.routers.api.rule=Host(`traefik.domain.com`)" - - "traefik.http.routers.api.service=api@internal" - - "traefik.http.routers.api.middlewares=auth" - - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" - ``` - - ```json tab="Marathon" - "labels": { - "traefik.http.routers.api.rule": "Host(`traefik.domain.com`)", - "traefik.http.routers.api.service": "api@internal", - "traefik.http.routers.api.middlewares": "auth", - "traefik.http.middlewares.auth.basicauth.users": "test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" - } - ``` - - ```yaml tab="Rancher" - # Dynamic Configuration - labels: - - "traefik.http.routers.api.rule=Host(`traefik.domain.com`)" - - "traefik.http.routers.api.service=api@internal" - - "traefik.http.routers.api.middlewares=auth" - - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" - ``` - - ```toml tab="File (TOML)" - # Dynamic Configuration - [http.routers.my-api] - rule = "Host(`traefik.domain.com`)" - service = "api@internal" - middlewares = ["auth"] - - [http.middlewares.auth.basicAuth] - users = [ - "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", - "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0", - ] - ``` - - ```yaml tab="File (YAML)" - # Dynamic Configuration - http: - routers: - api: - rule: Host(`traefik.domain.com`) - service: api@internal - middlewares: - - auth - middlewares: - auth: - basicAuth: - users: - - "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/" - - "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0" - ``` + --8<-- "content/operations/include-api-examples.md" ### Dashboard Router Rule diff --git a/docs/content/operations/include-api-examples.md b/docs/content/operations/include-api-examples.md new file mode 100644 index 000000000..8992b5101 --- /dev/null +++ b/docs/content/operations/include-api-examples.md @@ -0,0 +1,69 @@ +```yaml tab="Docker" +# Dynamic Configuration +labels: + - "traefik.http.routers.api.rule=Host(`traefik.domain.com`)" + - "traefik.http.routers.api.service=api@internal" + - "traefik.http.routers.api.middlewares=auth" + - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" +``` + +```yaml tab="Docker (Swarm)" +# Dynamic Configuration +deploy: + labels: + - "traefik.http.routers.api.rule=Host(`traefik.domain.com`)" + - "traefik.http.routers.api.service=api@internal" + - "traefik.http.routers.api.middlewares=auth" + - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" + # Dummy service for Swarm port detection. The port can be any valid integer value. + - "traefik.http.services.dummy-svc.loadbalancer.server.port=9999" +``` + +```json tab="Marathon" +"labels": { + "traefik.http.routers.api.rule": "Host(`traefik.domain.com`)", + "traefik.http.routers.api.service": "api@internal", + "traefik.http.routers.api.middlewares": "auth", + "traefik.http.middlewares.auth.basicauth.users": "test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" +} +``` + +```yaml tab="Rancher" +# Dynamic Configuration +labels: + - "traefik.http.routers.api.rule=Host(`traefik.domain.com`)" + - "traefik.http.routers.api.service=api@internal" + - "traefik.http.routers.api.middlewares=auth" + - "traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/,test2:$$apr1$$d9hr9HBB$$4HxwgUir3HP4EsggP/QNo0" +``` + +```toml tab="File (TOML)" +# Dynamic Configuration +[http.routers.my-api] + rule = "Host(`traefik.domain.com`)" + service = "api@internal" + middlewares = ["auth"] + +[http.middlewares.auth.basicAuth] + users = [ + "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", + "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0", + ] +``` + +```yaml tab="File (YAML)" +# Dynamic Configuration +http: + routers: + api: + rule: Host(`traefik.domain.com`) + service: api@internal + middlewares: + - auth + middlewares: + auth: + basicAuth: + users: + - "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/" + - "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0" +``` diff --git a/docs/mkdocs.yml b/docs/mkdocs.yml index 3a111788c..45e82db52 100644 --- a/docs/mkdocs.yml +++ b/docs/mkdocs.yml @@ -42,6 +42,9 @@ extra_javascript: plugins: - search + - exclude: + glob: + - include-*.md # https://squidfunk.github.io/mkdocs-material/extensions/admonition/ # https://facelessuser.github.io/pymdown-extensions/ diff --git a/docs/requirements.txt b/docs/requirements.txt index e6552aa6a..c9f1cc3b3 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -3,3 +3,4 @@ pymdown-extensions==6.0 mkdocs-bootswatch==1.0 mkdocs-material==4.0.2 markdown-include==0.5.1 +mkdocs-exclude==1.0.2