annotate README.md @ 12:84384cccda0e

bubfix subpaths and remove hardcode
author atarwn@g5
date Mon, 23 Mar 2026 12:05:05 +0500
parents 3e7247db5c6e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
1 # d2o
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
2
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
3 Минималистичный веб-сервер на Go с конфигурацией в формате ICF.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
4
12
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
5 ## Сборка
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
6
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
7 Обязательные компоненты:
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
8 - go
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
9
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
10 Рекомендуемые:
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
11 - just
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
12 - lowdown
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
13
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
14 Сборка и установка:
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
15
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
16 ```
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
17 $ just build # просто сборка
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
18 $ just install # сборка и установка
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
19 ```
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
20
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
21 Если вы скачали только обязательные компоненты
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
22
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
23 ```
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
24 $ go build -o d2o .
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
25 ```
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
26
1
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
27 ## Структура проекта
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
28
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
29 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
30 d2o/
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
31 go.mod
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
32 cmd/d2o/
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
33 main.go — точка входа, HTTP-обработчик, сборка листеров
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
34 icf/
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
35 icf.go — парсер формата ICF (переиспользуемая библиотека)
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
36 fcgi/
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
37 fcgi.go — минимальный FastCGI-клиент
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
38 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
39
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
40 ## Сборка и запуск
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
41
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
42 ```sh
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
43 go build -o d2o ./cmd/d2o/
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
44 ./d2o # читает /etc/d2obase
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
45 ./d2o /path/to/config # альтернативный путь
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
46 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
47
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
48 ---
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
49
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
50 ## Формат конфигурации ICF
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
51
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
52 **ICF (Inherited Configuration Format)** — текстовый формат правил вида «паттерн → директивы».
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
53 Вдохновлён синтаксисом bash и базами данных CoreDNS.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
54
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
55 ### Основные правила синтаксиса
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
56
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
57 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
58 ; Это комментарий
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
59
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
60 ; Переменная (без пробелов вокруг =)
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
61 KEY=value
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
62
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
63 ; Абстрактный блок (миксин)
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
64 @name
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
65 |> directive arg1 arg2
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
66
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
67 ; Конкретный блок с наследованием миксина
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
68 block.id @mixin
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
69 |> directive arg1 arg2
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
70
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
71 ; Блок с именованным capture-группой
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
72 <sub>.example.com
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
73 |> root /srv/$sub
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
74 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
75
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
76 ### Переменные
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
77
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
78 Объявляются как `KEY=value` на уровне файла. Подставляются через `$KEY` в аргументах директив.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
79
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
80 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
81 WWW=/srv/www
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
82 CERT=/etc/acme/example.com
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
83
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
84 example.com
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
85 |> root $WWW/root
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
86 |> tls $CERT.{crt,key}
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
87 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
88
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
89 ### Brace expansion
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
90
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
91 Аргумент `prefix.{a,b,c}` раскрывается в три отдельных аргумента: `prefix.a`, `prefix.b`, `prefix.c`.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
92 Порядок важен — используется для `tls`, где первый аргумент сертификат, второй ключ.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
93
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
94 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
95 |> tls /etc/acme/example.com.{crt,key}
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
96 ; эквивалентно:
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
97 |> tls /etc/acme/example.com.crt /etc/acme/example.com.key
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
98 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
99
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
100 ### Capture-группы
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
101
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
102 В идентификаторе блока `<name>` захватывает любую подстроку до следующего литерала.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
103 `<_>` — анонимный wildcard, ничего не сохраняет.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
104
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
105 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
106 <sub>.example.com
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
107 |> root /srv/$sub ; $sub подставляется из захваченного значения
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
108
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
109 <_>.static.example.com
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
110 |> root /srv/static ; совпадает с чем угодно, capture не нужен
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
111 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
112
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
113 Capture жадный слева: `<sub>.example.com` на запрос `a.b.example.com` даст `sub=a.b`.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
114
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
115 ### Кавычки в аргументах
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
116
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
117 Аргументы с пробелами берутся в двойные кавычки:
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
118
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
119 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
120 |> fcgi unix:/run/php-fpm.sock "*.php"
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
121 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
122
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
123 ### Абстрактные блоки и наследование
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
124
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
125 `@name` задаёт набор директив без привязки к паттерну.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
126 Конкретный блок наследует их через `block.id @name` — директивы миксина идут первыми, директивы блока их перекрывают.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
127
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
128 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
129 @base
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
130 |> port 80
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
131 |> port+tls 443
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
132
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
133 example.com @base
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
134 |> root /srv/www ; наследует port 80 и port+tls 443
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
135
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
136 other.com @base
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
137 |> root /srv/other ; то же самое
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
138 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
139
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
140 ### Матчинг блоков
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
141
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
142 - Домен матчится точно (с учётом capture-групп).
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
143 - Путь матчится как префикс: блок `example.com/api` сработает на `/api/users`.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
144 - При нескольких совпадениях выигрывает наиболее специфичный (больше совпавших литеральных символов).
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
145 - Сначала проверяется `host/path`, потом `host`.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
146
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
147 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
148 example.com
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
149 |> root /srv/www
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
150
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
151 example.com/api
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
152 |> rprx 127.0.0.1:8080 ; перекрывает блок выше для /api/*
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
153 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
154
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
155 ---
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
156
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
157 ## Конфигурация d2o
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
158
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
159 Файл по умолчанию: `/etc/d2obase`
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
160
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
161 ### @d2o — настройки сервера
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
162
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
163 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
164 @d2o
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
165 |> threads 512 ; GOMAXPROCS
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
166 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
167
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
168 | Директива | Аргументы | Описание |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
169 |------------|-----------|----------|
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
170 | `threads` | N | Количество потоков ОС (GOMAXPROCS) |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
171
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
172 ### port — HTTP-листенер
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
173
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
174 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
175 |> port 80
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
176 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
177
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
178 | # | Тип | Описание |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
179 |---|-------|--------------|
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
180 | 1 | `int` | Номер порта |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
181
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
182 ### port+tls — HTTPS-листенер
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
183
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
184 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
185 |> port+tls 443
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
186 ; сертификат берётся из директивы tls того же блока
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
187 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
188
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
189 Знак `+` в имени директивы — обычный символ, не оператор.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
190
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
191 | # | Тип | Описание |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
192 |---|--------|-----------------------------------------------|
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
193 | 1 | `int` | Номер порта |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
194 | 2 | `path` | Путь к сертификату (необязателен, если есть `tls`) |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
195 | 3 | `path` | Путь к ключу (необязателен, если есть `tls`) |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
196
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
197 ### tls — пути к сертификату и ключу
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
198
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
199 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
200 |> tls /etc/acme/example.com.{crt,key}
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
201 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
202
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
203 Используется как источник сертификата для `port+tls` в том же блоке, если пути не указаны явно.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
204
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
205 | # | Тип | Описание |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
206 |---|--------|-------------------|
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
207 | 1 | `path` | Путь к сертификату |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
208 | 2 | `path` | Путь к ключу |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
209
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
210 ### root — отдача статики
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
211
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
212 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
213 |> root /srv/www/example.com
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
214 |> root /srv/www/example.com hide ; листинг запрещён (по умолчанию)
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
215 |> root /srv/www/example.com show ; листинг разрешён, index-файл index.html
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
216 |> root /srv/www/example.com show index.php index.html ; свои index-файлы
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
217 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
218
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
219 | # | Тип | Описание |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
220 |---|--------|---------------------------------|
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
221 | 1 | `path` | Корневая директория |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
222 | 2 | `show\|hide` | Режим директорий (по умолчанию `hide`) |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
223 | 3–14 | `filename` | Index-файлы (только с `show`), проверяются по порядку |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
224
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
225 При `show`: сначала ищутся index-файлы по списку, если ни один не найден — отдаётся листинг директории.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
226 При `hide` или без аргумента: запрос к директории возвращает 403.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
227
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
228 ### fcgi — FastCGI
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
229
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
230 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
231 |> fcgi unix:/run/php-fpm.sock
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
232 |> fcgi unix:/run/php-fpm.sock "*.php" ; только .php файлы
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
233 |> fcgi 127.0.0.1:9000 "*.php"
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
234 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
235
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
236 | # | Тип | Описание |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
237 |---|---------|----------------------------------------------------|
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
238 | 1 | `addr` | Адрес сокета: `unix:/path` или `host:port` |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
239 | 2 | `glob` | Паттерн файлов (по умолчанию `*`, все запросы) |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
240
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
241 Если glob не совпадает, запрос падает в `root` (если задан).
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
242
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
243 ### rprx — обратный прокси
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
244
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
245 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
246 |> rprx 127.0.0.1:3000
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
247 |> rprx http://127.0.0.1:3000
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
248 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
249
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
250 | # | Тип | Описание |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
251 |---|-------|---------------------------------|
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
252 | 1 | `url` | Адрес backend (схема необязательна, по умолчанию `http://`) |
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
253
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
254 ### Приоритет директив
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
255
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
256 При одновременном наличии нескольких директив порядок обработки: **rprx > fcgi > root**.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
257
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
258 ---
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
259
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
260 ## Пример полного конфига
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
261
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
262 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
263 ; /etc/d2obase
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
264
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
265 ACME=/etc/acme/qwaderton.org
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
266 WWW=/srv/www/qwaderton.org
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
267
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
268 @d2o
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
269 |> threads 512
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
270
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
271 @ports
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
272 |> tls $ACME.{crt,key}
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
273 |> port 80
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
274 |> port+tls 443
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
275
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
276 qwaderton.org @ports
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
277 |> root $WWW/root show index.php index.html
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
278
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
279 qwaderton.org/webfeather @ports
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
280 |> root $WWW/root/webfeather
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
281 |> fcgi unix:/run/php-fpm.sock *.php
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
282
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
283 <sub>.qwaderton.org @ports
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
284 |> root $WWW/$sub
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
285 ```
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
286
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
287 ---
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
288
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
289 ## Известные ограничения
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
290
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
291 - **Один миксин на блок.** Множественное наследование не поддерживается.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
292 - **Brace expansion без вложенности.** `{a,{b,c}}` не работает.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
293 - **FastCGI — один запрос на соединение.** Keep-alive с FPM не реализован.
3e7247db5c6e show index.html
Atarwn Gard <a@qwa.su>
parents:
diff changeset
294 - **Нет HTTP→HTTPS редиректа** из коробки — нужно реализовывать отдельным блоком на порту 80.
12
84384cccda0e bubfix subpaths and remove hardcode
atarwn@g5
parents: 1
diff changeset
295 - **Нет hot reload** конфига — требуется перезапуск процесса.