> For the complete documentation index, see [llms.txt](https://gitbook.gpg123.vip/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.gpg123.vip/traefik-yi-ge-qiang-da-de-dai-li-pei-zhi-gong-ju/ji-yu-wen-jian/shi-jian-an-li.md).

# 实践案例

## 准备环境

* [x] 拥有一个域名
* [x] 域名解析到服务器ip
* [x] 自有ssl或开启ACME 自动生成HTTPS证书

## http/https

{% code title="" %}

```
http:
  routers:
    home-router:
      entryPoints:
        - http
        - https
```

{% endcode %}

## router

{% code title="" %}

```
routers:
  home-router:
    entryPoints:
      - http
      - https
```

{% endcode %}

## middleware

{% code title="" fullWidth="false" %}

```yaml
#中间件
middlewares:
  home-middleware:
    addPrefix:
      prefix: "/"
```

{% endcode %}

## service

{% code title="" %}

```yaml
services:
  # Define how to reach an existing service on our infrastructure
  home-service:
    loadBalancer:
      servers:
        - url: http://server.gpg123.vip:8081
```

{% endcode %}

## 完整文件：

{% code title="home.yml" %}

```yaml
http:
  routers:
    home-router:
      entryPoints:
        - http
        - https
      middlewares:
        - home-middleware
      service: home-service
      rule: "Host(`gpg123.vip`) && PathPrefix(`/`)"
      tls:
        certResolver: "myCertResolver"
  #中间件
  middlewares:
    home-middleware:
      addPrefix:
        prefix: "/"
  services:
    # Define how to reach an existing service on our infrastructure
    home-service:
      loadBalancer:
        servers:
          - url: http://server.gpg123.vip:8081
```

{% endcode %}

更新到traefik配置文件目录

<figure><img src="/files/UzB3xS7JEKVwyndTVttu" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://gitbook.gpg123.vip/traefik-yi-ge-qiang-da-de-dai-li-pei-zhi-gong-ju/ji-yu-wen-jian/shi-jian-an-li.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
