gitea

Development moved to Codeberg


date: "2016-12-26T16:00:00+02:00" title: "配置说明" slug: "config-cheat-sheet" weight: 20 toc: false draft: false menu: sidebar: parent: "advanced" name: "配置说明" weight: 20

identifier: "config-cheat-sheet"

配置说明

这是针对Gitea配置文件的说明,你可以了解Gitea的强大配置。需要说明的是,你的所有改变请修改 custom/conf/app.ini 文件而不是源文件。所有默认值可以通过 app.example.ini 查看到。如果你发现 %(X)s 这样的内容,请查看 ini 这里的说明。标注了 :exclamation: 的配置项表明除非你真的理解这个配置项的意义,否则最好使用默认值。

{{< toc >}}

Overall (DEFAULT)

Repository (repository)

Repository - Release (repository.release)

UI (ui)

UI - Admin (ui.admin)

Markdown (markdown)

Server (server)

Database (database)

Indexer (indexer)

Security (security)

Service (service)

Service - Expore (service.explore)

Webhook (webhook)

Mailer (mailer)

说明:实际上 Gitea 仅仅支持基于 STARTTLS 的 SMTP。

Cache (cache)

Cache - LastCommitCache settings (cache.last_commit)

Session (session)

Picture (picture)

Attachment (attachment)

关于 ALLOWED_TYPES, 在 (*)unix 系统中可以使用file -I <filename> 来快速获得对应的 MIME type

$ file -I test00.tar.xz
test00.tar.xz: application/x-xz; charset=binary

$ file --mime test00.xlsx
test00.xlsx: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet; charset=binary

file -I test01.xls
test01.xls: application/vnd.ms-excel; charset=binary

Log (log)

Cron (cron)

Cron - Update Mirrors (cron.update_mirrors)

Cron - Repository Health Check (cron.repo_health_check)

Cron - Repository Statistics Check (cron.check_repo_stats)

Cron - Update Migration Poster ID (cron.update_migration_poster_id)

Git (git)

Git - 超时设置 (git.timeout)

API (api)

Markup (markup)

外部渲染工具支持,你可以用你熟悉的文档渲染工具. 比如一下将新增一个名字为 asciidoc 的渲染工具which is followed markup. ini section. And there are some config items below.

[markup.asciidoc]
ENABLED = false
NEED_POSTPROCESS = true
FILE_EXTENSIONS = .adoc,.asciidoc
RENDER_COMMAND = "asciidoc --out-file=- -"
IS_INPUT_FILE = false

以下两个环境变量将会被传递给渲染命令:

如果 DISABLE_SANITIZER 为 false,则 Gitea 支持自定义渲染 HTML 的净化策略。以下例子将用 pandoc 支持 KaTeX 输出。

[markup.sanitizer.TeX]
; Pandoc renders TeX segments as <span>s with the "math" class, optionally
; with "inline" or "display" classes depending on context.
ELEMENT = span
ALLOW_ATTR = class
REGEXP = ^\s*((math(\s+|$)|inline(\s+|$)|display(\s+|$)))+
ALLOW_DATA_URI_IMAGES = true

多个净化规则可以被同时定义,只要section名称最后一位不重复即可。如: [markup.sanitizer.TeX-2]。 为了针对一种渲染类型进行一个特殊的净化策略,必须使用形如 [markup.sanitizer.asciidoc.rule-1] 的方式来命名 seciton。 如果此规则没有匹配到任何渲染类型,它将会被应用到所有的渲染类型。

Time (time)

Task (task)

Migrations (migrations)

LFS (lfs)

LFS 的存储配置。 如果 STORAGE_TYPE 为空,则此配置将从 [storage] 继承。如果不为 local 或者 minio 而为 xxx, 则从 [storage.xxx] 继承。当继承时, PATH 默认为 data/lfsMINIO_BASE_PATH 默认为 lfs/

Storage (storage)

Attachments, lfs, avatars and etc 的默认存储配置。

你也可以自定义一个存储的名字如下:

[storage.my_minio]
STORAGE_TYPE = minio
; Minio endpoint to connect only available when STORAGE_TYPE is `minio`
MINIO_ENDPOINT = localhost:9000
; Minio accessKeyID to connect only available when STORAGE_TYPE is `minio`
MINIO_ACCESS_KEY_ID =
; Minio secretAccessKey to connect only available when STORAGE_TYPE is `minio`
MINIO_SECRET_ACCESS_KEY =
; Minio bucket to store the attachments only available when STORAGE_TYPE is `minio`
MINIO_BUCKET = gitea
; Minio location to create bucket only available when STORAGE_TYPE is `minio`
MINIO_LOCATION = us-east-1
; Minio enabled ssl only available when STORAGE_TYPE is `minio`
MINIO_USE_SSL = false

然后你在 [attachment], [lfs] 等中可以把这个名字用作 STORAGE_TYPE 的值。

Repository Archive Storage (storage.repo-archive)

Repository archive 的存储配置。 如果 STORAGE_TYPE 为空,则此配置将从 [storage] 继承。如果不为 local 或者 minio 而为 xxx, 则从 [storage.xxx] 继承。当继承时, PATH 默认为 data/repo-archiveMINIO_BASE_PATH 默认为 repo-archive/

Proxy (proxy)

i.e.

PROXY_ENABLED = true
PROXY_URL = socks://127.0.0.1:1080
PROXY_HOSTS = *.github.com

Other (other)