-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvhosts.json
More file actions
406 lines (406 loc) · 13.4 KB
/
vhosts.json
File metadata and controls
406 lines (406 loc) · 13.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
{
"description": "FastHTTP Virtual Host Configuration Examples",
"examples": [
{
"name": "Basic Static Website",
"description": "Simple static website serving HTML, CSS, and JavaScript files",
"config": {
"serverName": "example.com",
"documentRoot": "/var/www/example.com/public_html",
"user": "www-data",
"group": "www-data",
"directoryIndex": "index.html index.htm"
}
},
{
"name": "PHP Website with FastCGI (TCP)",
"description": "PHP website using FastCGI over TCP connection",
"config": {
"serverName": "phpapp.com",
"documentRoot": "/var/www/phpapp.com/public_html",
"user": "phpapp",
"group": "phpapp",
"phpProxyFCGI": "127.0.0.1:9000",
"directoryIndex": "index.php index.html"
}
},
{
"name": "PHP Website with FastCGI Proxy (Unix Socket)",
"description": "PHP website using FastCGI over Unix socket proxy",
"config": {
"serverName": "phpapp2.com",
"documentRoot": "/var/www/phpapp2.com/public_html",
"user": "phpapp2",
"group": "phpapp2",
"proxyUnixSocket": "/run/php-fpm/php-fpm.sock",
"proxyType": "fcgi",
"directoryIndex": "index.php index.html index.htm"
}
},
{
"name": "CGI Scripts Support",
"description": "Virtual host with CGI script execution support",
"config": {
"serverName": "cgi.example.com",
"documentRoot": "/var/www/cgi.example.com/public_html",
"user": "cgiuser",
"group": "cgigroup",
"cgiPath": "/cgi-bin",
"directoryIndex": "index.cgi index.html"
}
},
{
"name": "HTTP Proxy to Backend Service",
"description": "Proxies requests to a backend HTTP service over Unix socket",
"config": {
"serverName": "api.example.com",
"documentRoot": "/var/www/api.example.com",
"user": "apiuser",
"group": "apiuser",
"proxyUnixSocket": "/var/run/backend-api.sock",
"proxyType": "http",
"proxyPath": "/api"
}
},
{
"name": "FastCGI Proxy with Path Prefix",
"description": "Proxies specific paths to FastCGI backend, rest serves static files",
"config": {
"serverName": "mixed.example.com",
"documentRoot": "/var/www/mixed.example.com/public_html",
"user": "mixeduser",
"group": "mixeduser",
"proxyUnixSocket": "/run/app-fcgi.sock",
"proxyType": "fcgi",
"proxyPath": "/app",
"directoryIndex": "index.html"
}
},
{
"name": "Custom Directory Index Order",
"description": "Virtual host with custom directory index file priority",
"config": {
"serverName": "custom.example.com",
"documentRoot": "/var/www/custom.example.com/public_html",
"user": "customuser",
"group": "customuser",
"directoryIndex": "home.php welcome.html index.php index.html"
}
},
{
"name": "HTTPS Virtual Host (with SSL)",
"description": "HTTPS virtual host configuration (SSL configuration would be separate)",
"config": {
"serverName": "secure.example.com",
"serverAlias": ["www.secure.example.com"],
"documentRoot": "/var/www/secure.example.com/public_html",
"user": "secureuser",
"group": "secureuser",
"directoryIndex": "index.php index.html"
}
},
{
"name": "Multiple Server Aliases",
"description": "Virtual host with multiple domain aliases",
"config": {
"serverName": "example.com",
"serverAlias": ["www.example.com", "example.net", "www.example.net"],
"documentRoot": "/var/www/example.com/public_html",
"user": "example",
"group": "example",
"directoryIndex": "index.html index.htm"
}
},
{
"name": "Complete Configuration with All Options",
"description": "Example showing all available configuration options",
"config": {
"listen": ["80", "8080"],
"serverName": "full.example.com",
"serverAlias": ["www.full.example.com"],
"documentRoot": "/var/www/full.example.com/public_html",
"user": "fulluser",
"group": "fullgroup",
"serverAdmin": "admin@full.example.com",
"errorLog": "/var/log/fasthttp/full.example.com-error.log",
"customLog": "/var/log/fasthttp/full.example.com-access.log",
"directoryIndex": "index.php index.html index.htm",
"phpProxyFCGI": "127.0.0.1:9000",
"cgiPath": "/cgi-bin",
"proxyUnixSocket": "/var/run/full-app.sock",
"proxyType": "fcgi",
"proxyPath": "/api"
}
}
],
"locationExamples": [
{
"name": "Virtual Host with Location Blocks",
"description": "Example showing location/directory-based configuration like nginx/httpd",
"config": {
"serverName": "example.com",
"documentRoot": "/var/www/example.com/public_html",
"user": "example",
"group": "example",
"directoryIndex": "index.php index.html",
"locations": [
{
"path": "/api",
"handler": "proxy",
"proxyUnixSocket": "/var/run/api-backend.sock",
"proxyType": "http"
},
{
"path": "/cgi-bin",
"handler": "cgi",
"cgiPath": "/cgi-bin"
},
{
"path": "/app",
"handler": "proxy",
"proxyUnixSocket": "/run/app-fcgi.sock",
"proxyType": "fcgi"
},
{
"path": "/static",
"handler": "static",
"directoryIndex": "index.html"
}
]
}
},
{
"name": "Mixed Configuration with Locations",
"description": "Virtual host with both global and location-specific handlers",
"config": {
"serverName": "mixed.example.com",
"documentRoot": "/var/www/mixed.example.com/public_html",
"user": "mixeduser",
"group": "mixeduser",
"phpProxyFCGI": "127.0.0.1:9000",
"locations": [
{
"path": "/api/v1",
"handler": "proxy",
"proxyUnixSocket": "/var/run/api-v1.sock",
"proxyType": "http"
},
{
"path": "/api/v2",
"handler": "proxy",
"proxyUnixSocket": "/var/run/api-v2.sock",
"proxyType": "http"
},
{
"path": "/legacy",
"handler": "cgi",
"cgiPath": "/legacy"
}
]
}
},
{
"name": "Location \"/\" as Catch-All",
"description": "Using location \"/\" as default/catch-all handler (like nginx location /)",
"config": {
"serverName": "catchall.example.com",
"documentRoot": "/var/www/catchall.example.com/public_html",
"user": "catchall",
"group": "catchall",
"locations": [
{
"path": "/api",
"handler": "proxy",
"proxyUnixSocket": "/var/run/api.sock",
"proxyType": "http"
},
{
"path": "/cgi-bin",
"handler": "cgi",
"cgiPath": "/cgi-bin"
},
{
"path": "/",
"handler": "proxy",
"proxyUnixSocket": "/run/default-fcgi.sock",
"proxyType": "fcgi",
"directoryIndex": "index.php index.html"
}
]
}
},
{
"name": "Location with Regex Matching",
"description": "Using regex patterns for location matching (like nginx location ~)",
"config": {
"serverName": "regex.example.com",
"documentRoot": "/var/www/regex.example.com/public_html",
"user": "regexuser",
"group": "regexuser",
"locations": [
{
"path": "^/api/v[0-9]+/",
"matchType": "regex",
"handler": "proxy",
"proxyUnixSocket": "/var/run/api-versioned.sock",
"proxyType": "http"
},
{
"path": "\\.(php|phtml)$",
"matchType": "regexCaseInsensitive",
"handler": "proxy",
"proxyUnixSocket": "/run/php-fpm.sock",
"proxyType": "fcgi"
},
{
"path": "^/static/.*\\.(css|js|jpg|png|gif)$",
"matchType": "regex",
"handler": "static"
},
{
"path": "/cgi-bin",
"matchType": "prefix",
"handler": "cgi",
"cgiPath": "/cgi-bin"
},
{
"path": "/",
"matchType": "prefix",
"handler": "static"
}
]
}
}
],
"notes": {
"directoryIndex": "Can be set globally in main config or per virtual host. Virtual host setting overrides global. Default order: index.html, index.htm, index.php",
"proxyType": "Can be 'http' for HTTP reverse proxy or 'fcgi' for FastCGI proxy. Default is 'http'",
"proxyPath": "Optional. If set, only requests matching this path prefix will be proxied. Other requests will be served as static files",
"cgiPath": "Path prefix where CGI scripts are located (e.g., '/cgi-bin'). Scripts in this path will be executed",
"phpProxyFCGI": "TCP address for PHP FastCGI (e.g., '127.0.0.1:9000')",
"proxyUnixSocket": "Unix socket path for proxy connections (e.g., '/var/run/app.sock')",
"user": "System user to run processes as (for CGI execution)",
"group": "System group to run processes as (for CGI execution)",
"locations": "Array of location blocks. Each location matches requests by path prefix or regex. Handler types: 'proxy', 'cgi', 'php', 'static'",
"matchType": "Location match type: 'prefix' (default, matches by path prefix, longest wins), 'regex' (matches by regex pattern), 'regexCaseInsensitive' (case-insensitive regex). Regex matches have higher priority than prefix matches.",
"listen": "Array of ports that a virtual host should listen on. If empty, virtual host is available on all ports. Global 'listen' ports apply to all virtual hosts. Virtual host 'listen' ports restrict that virtual host to specific ports."
},
"multiPortExamples": [
{
"name": "Multiple Global Ports",
"description": "Server listens on multiple ports globally",
"config": {
"listen": ["80", "8080", "8888"],
"virtualHosts": [
{
"serverName": "example.com",
"documentRoot": "/var/www/example.com"
}
]
}
},
{
"name": "Virtual Host on Specific Port",
"description": "Different virtual hosts on different ports",
"config": {
"virtualHosts": [
{
"serverName": "app1.example.com",
"listen": ["8080"],
"documentRoot": "/var/www/app1",
"locations": [
{
"path": "\\.php$",
"matchType": "regexCaseInsensitive",
"handler": "proxy",
"proxyUnixSocket": "/run/app1-fcgi.sock",
"proxyType": "fcgi"
}
]
},
{
"serverName": "app2.example.com",
"listen": ["8081"],
"documentRoot": "/var/www/app2",
"locations": [
{
"path": "\\.php$",
"matchType": "regexCaseInsensitive",
"handler": "proxy",
"proxyUnixSocket": "/run/app2-fcgi.sock",
"proxyType": "fcgi"
}
]
},
{
"serverName": "api.example.com",
"listen": ["9090"],
"documentRoot": "/var/www/api",
"locations": [
{
"path": "/",
"handler": "proxy",
"proxyUnixSocket": "/var/run/api.sock",
"proxyType": "http"
}
]
}
]
}
},
{
"name": "Virtual Host on Multiple Ports",
"description": "Single virtual host accessible on multiple ports",
"config": {
"virtualHosts": [
{
"serverName": "example.com",
"listen": ["80", "8080", "8888"],
"documentRoot": "/var/www/example.com/public_html",
"locations": [
{
"path": "\\.php$",
"matchType": "regexCaseInsensitive",
"handler": "proxy",
"proxyUnixSocket": "/run/php-fpm.sock",
"proxyType": "fcgi"
}
]
}
]
}
},
{
"name": "Mixed Port Configuration",
"description": "Some virtual hosts on specific ports, others on all ports",
"config": {
"listen": ["80"],
"virtualHosts": [
{
"serverName": "default.example.com",
"documentRoot": "/var/www/default",
"listen": []
},
{
"serverName": "admin.example.com",
"listen": ["8080"],
"documentRoot": "/var/www/admin"
},
{
"serverName": "api.example.com",
"listen": ["9090"],
"documentRoot": "/var/www/api",
"locations": [
{
"path": "/",
"handler": "proxy",
"proxyUnixSocket": "/var/run/api.sock",
"proxyType": "http"
}
]
}
]
}
}
]
}