> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiI1MWFjYmIwOC00NTYwLTQwZjQtYmNjMS0xOWU3ZDliNzc5NTMiLCJleHAiOjE3NzgyNzY5ODcsImlhdCI6MTc3ODI3NjY4N30.Rs5M1VK_GELCjIkrbmfvqF3fqFPOkHkb87IIijnp7y4
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# 自托管文档

> Fern 支持自托管，让您可以在自己的基础设施上运行文档站点。

<Warning title="企业功能">
  此功能仅适用于[企业计划](https://buildwithfern.com/pricing)。如需开始使用，请联系 [support@buildwithfern.com](mailto:support@buildwithfern.com)。
</Warning>

Fern 文档网站默认托管在 Fern 的基础设施上。自托管允许您在自己的基础设施上部署文档站点，以满足特定的[安全性](/learn/docs/security/overview)或合规要求。

## 何时使用自托管

自托管通常适用于在无互联网接入环境中运行的组织、有严格合规要求的组织，或需要完全控制文档服务器的组织。

当您选择自托管时，您需要负责服务器设置、安全性、维护，以及决定如何让用户访问文档。

<Warning>
  除非您有特定要求无法使用 Fern 的默认托管服务，我们建议**使用我们的托管解决方案**，以便更轻松地进行设置和维护。
</Warning>

<Accordion title="功能支持">
  自托管部署包含 Fern 文档网站的核心功能。但是，需要外部连接到 Fern 云服务的功能在自托管环境中不可用。

  <Info title="扩展功能支持">
    针对自托管部署的 PDF 导出和**离线 AI 聊天功能**正在开发中。如果您对这些功能感兴趣，请[联系我们](mailto:support@buildwithfern.com)。
  </Info>

  | 功能                                                                | 是否支持 |
  | ----------------------------------------------------------------- | ---- |
  | [AI 生成示例](/learn/docs/ai-features/ai-examples)                    | 否    |
  | [分析 + 集成](/learn/docs/integrations/overview)                      | 否    |
  | [公告横幅](/learn/docs/customization/announcement-banner)             | 是    |
  | [API 浏览器](/learn/docs/api-references/api-explorer)                | 是    |
  | [API 密钥注入](/learn/docs/authentication/features/api-key-injection) | 是    |
  | [API 参考](/learn/docs/api-references/overview)                     | 是    |
  | [Ask Fern](/learn/docs/ai-features/ask-fern/overview)             | 否    |
  | [更新日志页面](/learn/docs/configuration/changelogs)                    | 是    |
  | [组件库](/learn/docs/writing-content/components/overview)            | 是    |
  | [自定义品牌和主题](/learn/docs/configuration/site-level-settings)         | 是    |
  | [自定义 CSS 和 JS](/learn/docs/customization/custom-css-js)           | 是    |
  | [自定义域名](/learn/docs/preview-publish/setting-up-your-domain)       | 是    |
  | [自定义 React 组件](/learn/docs/customization/custom-react-components) | 是    |
  | [深色/浅色模式](/learn/docs/configuration/site-level-settings)          | 是    |
  | [嵌入模式](/learn/docs/customization/embedded-mode)                   | 是    |
  | [Fern Editor](/learn/docs/writing-content/fern-editor)            | 否    |
  | [Fern Writer](/learn/docs/ai-features/fern-writer)                | 否    |
  | [页眉和页脚自定义](/learn/docs/customization/header-and-footer)           | 是    |
  | [健康检查端点](/learn/docs/self-hosted/health-check-endpoints)          | 是    |
  | [HTTP 代码片段](/learn/docs/api-references/http-snippets)             | 是    |
  | [Intercom](/learn/docs/integrations/support/intercom)             | 否    |
  | [基于 JWT 的身份验证](/learn/docs/self-hosted/authentication)            | 是    |
  | [llms.txt](/learn/docs/ai-features/llms-txt)                      | 是    |
  | [导航和侧边栏](/learn/docs/configuration/navigation)                    | 是    |
  | [OAuth](/learn/docs/authentication/setup/oauth)                   | 否    |
  | [页面内反馈](/learn/docs/self-hosted/set-up#on-page-feedback)          | 是    |
  | [页面级访问控制](/learn/docs/configuration/page-level-settings)          | 是    |
  | [密码保护](/learn/docs/self-hosted/authentication)                    | 是    |
  | [RBAC](/learn/docs/authentication/features/rbac)                  | 否    |
  | [重定向](/learn/docs/seo/redirects)                                  | 是    |
  | [可复用代码片段](/learn/docs/writing-content/reusable-snippets)          | 是    |
  | [SDK 代码片段](/learn/docs/api-references/sdk-snippets)               | 是    |
  | [搜索](/learn/docs/customization/search)                            | 是    |
  | [SEO 元数据](/learn/docs/seo/setting-seo-metadata)                   | 是    |
  | [SSO](/learn/docs/authentication/setup/sso)                       | 否    |
  | [标签页](/learn/docs/configuration/tabs)                             | 是    |
  | [产品](/learn/docs/configuration/products)                          | 是    |
  | [版本](/learn/docs/configuration/versions)                          | 是    |
</Accordion>

## 设置流程

Fern 以即时可运行的 Docker 容器形式提供您的文档站点，您可以在自己的基础设施上部署。详细说明请参见[设置自托管文档](/learn/docs/self-hosted/set-up)。

1. **通过 Docker Hub 进行身份验证** - 使用 Fern 提供的组织访问令牌 (OAT) 登录
2. **下载 Docker 镜像** - 拉取 `fernenterprise/fern-self-hosted` 镜像
3. **上传您的 fern 文件夹** - 将您的文档源文件添加到容器中
4. **运行容器** - 使用标准 Docker 命令启动本地服务器
5. **部署** - 设置服务器环境并发布文档
6. **接收更新的 Docker 镜像** - Fern 发布新版本的 Docker 镜像，您的团队可以评估并在准备就绪时进行部署。

### 架构图

```mermaid
sequenceDiagram
    autonumber
    participant F as Fern
    participant C as 客户
    participant S as 客户服务器

    F->>C: 提供 Docker 镜像
    C->>S: 上传 fern 文件夹
    C->>S: 运行 Docker 命令
    S->>S: 在本地托管文档
    F->>C: 发布更新的 Docker 镜像
    C->>C: 评估新版本
    C->>S: 部署更新的镜像
```

## 监控和健康检查

自托管容器在端口 8081 上包含[健康检查端点](./health-check-endpoints)，用于 Kubernetes 和 Helm 部署。