-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
528 lines (497 loc) · 19.6 KB
/
index.html
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Unit Configurator – Nginx Unit Configuration Tool</title>
<!-- Canonical URL -->
<link rel="canonical" href="https://nxunit.pavlusha.me">
<link rel="alternate" href="https://www.nxunit.pavlusha.me" hreflang="x-default">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<!-- Meta description and keywords -->
<meta name="description"
content="Easily create and edit Nginx Unit configurations with a user-friendly interface..">
<meta name="keywords" content="unit, nginx unit, configurator, server settings, json config, backend, deployment">
<meta name="author" content="Pavel Zavadski">
<meta name="robots" content="index, follow">
<!-- Open Graph (Facebook, LinkedIn, etc.) -->
<meta property="og:title" content="Unit Configurator – Nginx Unit Configuration Tool">
<meta property="og:description"
content="Easily create and edit Nginx Unit configurations with a user-friendly interface.">
<!-- <meta property="og:image" content="https://nxunit.pavlusha.me/images/unit-configurator-preview.jpg">-->
<!-- <meta property="og:image:alt" content="Unit Configurator interface screenshot">-->
<meta property="og:url" content="https://nxunit.pavlusha.me">
<meta property="og:type" content="website">
<meta property="og:site_name" content="Unit Configurator">
<!-- Twitter Cards -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Unit Configurator – Nginx Unit Configuration Tool">
<meta name="twitter:description"
content="Easily create and edit Nginx Unit configurations with a user-friendly interface.">
<!-- <meta name="twitter:image" content="https://nxunit.pavlusha.me/images/unit-configurator-preview.jpg">-->
<!-- <meta name="twitter:image:alt" content="Unit Configurator interface screenshot">-->
<meta name="twitter:creator" content="@PavelZavadski">
<!-- Canonical URL -->
<link rel="canonical" href="https://nxunit.pavlusha.me/unit-configurator">
<!-- Favicon -->
<link rel="icon" type="image/png" href="https://nxunit.pavlusha.me/favicon.png">
<title>Unit Configurator</title>
<link href="src/app.css" rel="stylesheet">
</head>
<body class="bg-gray-100 dark:bg-gray-800 py-10 dark:text-white">
<div class="max-w-6xl mx-auto bg-white dark:bg-gray-600 p-6 rounded-lg shadow-md">
<h1 class="text-2xl font-bold mb-4">Nginx Unit Configurator</h1>
<div class="flex">
<div class="w-1/4 border-r">
<ul class="space-y-2">
<li>
<button class="w-full text-left p-2 hover:bg-gray-200" onclick="showTab('startup')">Startup Config
</button>
</li>
<li>
<button class="w-full text-left p-2 hover:bg-gray-200" onclick="showTab('build')">Build Config
</button>
</li>
</ul>
</div>
<div class="w-3/4 p-4">
<!-- Startup Config Tab -->
<div id="startup" class="tab-content">
<h2 class="text-2xl font-bold mb-4">Nginx Unit Startup Configurator</h2>
<form id="startup-form" class="space-y-4">
<div id="startup-form-fields" class="grid grid-cols-1 md:grid-cols-2 gap-5"></div>
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600">Generate
Command
</button>
</form>
<div class="mt-4">
<h3 class="text-lg font-semibold">Generated Command:</h3>
<div class="relative">
<input id="output-startup" type="text" readonly
class="bg-gray-200 dark:bg-gray-900 text-gray-800 dark:text-gray-200 p-2 rounded-md w-full pr-20">
<button class="absolute top-1/2 right-2 transform -translate-y-1/2 bg-blue-500 text-white px-3 py-1 rounded-md text-sm hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-400"
onclick="copyCommand('output-startup')">Copy</button>
</div>
</div>
</div>
<!-- Build Config Tab -->
<div id="build" class="tab-content hidden">
<h2 class="text-2xl font-bold mb-4">Nginx Unit Build Configurator</h2>
<form id="build-form" class="space-y-4">
<div id="build-form-fields" class="grid grid-cols-1 md:grid-cols-2 gap-5"></div>
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded-md hover:bg-blue-600">Generate
Command
</button>
</form>
<div class="mt-4">
<h3 class="text-lg font-semibold">Generated Command:</h3>
<div class="relative">
<input id="output-build" type="text" readonly
class="bg-gray-200 dark:bg-gray-900 text-gray-800 dark:text-gray-200 p-2 rounded-md w-full pr-20">
<button class="absolute top-1/2 right-2 transform -translate-y-1/2 bg-blue-500 text-white px-3 py-1 rounded-md text-sm hover:bg-blue-600 focus:outline-none focus:ring-2 focus:ring-blue-400"
onclick="copyCommand('output-build')">Copy</button>
</div>
</div>
</div>
</div>
</div>
</div>
<template id="input-template">
<input type="text"
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"/>
</template>
<script src="node_modules/flowbite/dist/flowbite.min.js"></script>
<script>
function copyCommand(outputId) {
const commandInput = document.getElementById(outputId);
if (!commandInput) return;
const text = commandInput.value.trim();
navigator.clipboard.writeText(text).then(() => {
alert('Command copied to clipboard!');
}).catch(err => {
console.error('Failed to copy command: ', err);
});
}
const buildFormFields = [
{
id: 'cc',
name: 'C Compiler Path',
description: 'Custom C compiler pathname',
placeholder: '/usr/bin/gcc',
type: 'text'
},
{
id: 'cc_opt',
name: "Extra Compiler Option",
description: 'Extra options for the C compiler',
placeholder: '-O2 -Wall',
type: 'text'
},
{
id: 'ld_opt',
name: 'Extra Linker Options',
description: 'Extra options for the linker',
placeholder: '-L/usr/local/lib',
type: 'text'
},
{
id: 'group',
name: 'Group Name',
description: 'Group name to run Unit’s non-privileged processes',
placeholder: 'unit',
type: 'text'
},
{
id: 'user',
name: 'User Name',
description: 'Username to run Unit’s non-privileged processes',
placeholder: 'nobody',
type: 'text'
},
{
id: 'enable_debug',
name: 'Enable Debug',
description: 'Enable debug logging',
type: 'checkbox'
},
{
id: 'disable_ipv6',
name: 'Disable IPv6',
description: 'Disable IPv6 support',
type: 'checkbox'
},
{
id: 'disable_unix_sockets',
name: 'Disable UNIX Sockets',
description: 'Disable UNIX sockets support',
type: 'checkbox'
},
{
id: 'openssl',
name: 'OpenSSL Support',
description: 'Enable OpenSSL support',
type: 'checkbox'
},
{
id: 'enable_njs',
name: 'Enable njs Support',
description: 'Enable njs scripting support',
type: 'checkbox'
},
{
id: 'prefix',
name: '--prefix=PREFIX',
description: 'Destination directory prefix for path options. Default is /usr/local.',
placeholder: '/usr/local',
type: 'text'
},
{
id: 'exec_prefix',
name: '--exec-prefix=EXEC_PREFIX',
description: 'Destination directory prefix for executable directories. Default is PREFIX value.',
placeholder: '/usr/local',
type: 'text'
},
{
id: 'bindir',
name: '--bindir=BINDIR',
description: 'Directory path for client executables. Default is EXEC_PREFIX/bin.',
placeholder: '/usr/local/bin',
type: 'text'
},
{
id: 'sbindir',
name: '--sbindir=SBINDIR',
description: 'Directory path for server executables. Default is EXEC_PREFIX/sbin.',
placeholder: '/usr/local/sbin',
type: 'text'
},
{
id: 'includedir',
name: '--includedir=INCLUDEDIR',
description: 'Directory path for libunit header files. Default is PREFIX/include.',
placeholder: '/usr/local/include',
type: 'text'
},
{
id: 'libdir',
name: '--libdir=LIBDIR',
description: 'Directory path for libunit libraries. Default is EXEC_PREFIX/lib.',
placeholder: '/usr/local/lib',
type: 'text'
},
{
id: 'modulesdir',
name: '--modulesdir=MODULESDIR',
description: 'Directory path for Unit’s language modules. Default is LIBDIR/unit/modules.',
placeholder: '/usr/local/lib/unit/modules',
type: 'text'
},
{
id: 'datarootdir',
name: '--datarootdir=DATAROOTDIR',
description: 'Directory path for unitd(8) data storage. Default is PREFIX/share.',
placeholder: '/usr/local/share',
type: 'text'
},
{
id: 'mandir',
name: '--mandir=MANDIR',
description: 'Directory path where the man page is installed. Default is DATAROOTDIR/man.',
placeholder: '/usr/local/share/man',
type: 'text'
},
{
id: 'localstatedir',
name: '--localstatedir=LOCALSTATEDIR',
description: 'Directory path where Unit stores runtime state. Default is PREFIX/var.',
placeholder: '/usr/local/var',
type: 'text'
},
{
id: 'libstatedir',
name: '--libstatedir=LIBSTATEDIR',
description: 'Directory path for Unit’s runtime state storage. Default is LOCALSTATEDIR/run/unit.',
placeholder: '/usr/local/var/run/unit',
type: 'text'
},
{
id: 'logdir',
name: '--logdir=LOGDIR',
description: 'Directory path for Unit’s log. Default is LOCALSTATEDIR/log/unit.',
placeholder: '/usr/local/var/log/unit',
type: 'text'
},
{
id: 'runstatedir',
name: '--runstatedir=RUNSTATEDIR',
description: 'Directory path where Unit stores PID file and control socket. Default is LOCALSTATEDIR/run/unit.',
placeholder: '/usr/local/var/run/unit',
type: 'text'
},
{
id: 'control',
name: '--control=SOCKET',
description: 'Control API socket address. Default is unix:RUNSTATEDIR/control.unit.sock.',
placeholder: 'unix:/usr/local/var/run/unit/control.unit.sock',
type: 'text'
},
{
id: 'tmpdir',
name: '--tmpdir=TMPDIR',
description: 'Temporary file storage location. Default is /tmp.',
placeholder: '/tmp',
type: 'text'
}
]
const startupFormFields = [
{
id: 'control',
name: 'Control API Socket',
description: 'Control API socket address',
placeholder: '127.0.0.1:8080',
type: 'text'
},
{
id: 'control_mode',
name: 'Control Mode',
description: 'Control API socket access mode',
placeholder: '0600',
type: 'text'
},
{
id: 'control_user',
name: 'Control User',
description: 'Control API socket owner',
placeholder: 'root',
type: 'text'
},
{
id: 'control_group',
name: 'Control Group',
description: 'Control API socket group',
placeholder: 'unit',
type: 'text'
},
{
id: 'group',
name: 'Group Name',
description: 'Group name to run Unit’s non-privileged processes',
placeholder: 'unit',
type: 'text'
},
{
id: 'user',
name: 'User Name',
description: 'Username to run Unit’s non-privileged processes',
placeholder: 'nobody',
type: 'text'
},
{
id: 'log',
name: 'Log Path',
description: 'Log file pathname',
placeholder: '/var/log/unit.log',
type: 'text'
},
{
id: 'modules',
name: 'Modules Directory',
description: 'Modules directory pathname',
placeholder: '/usr/lib/unit/modules',
type: 'text'
},
{
id: 'pid',
name: 'PID File Path',
description: 'PID file pathname',
placeholder: '/run/unit.pid',
type: 'text'
},
{
id: 'state',
name: 'State Directory',
description: 'State directory pathname',
placeholder: '/var/lib/unit',
type: 'text'
},
{
id: 'tmp',
name: 'Temporary Directory',
description: 'Temporary directory pathname',
placeholder: '/tmp',
type: 'text'
},
{
id: 'no_daemon',
name: 'Run in Non-Daemon Mode',
description: 'Run in non-daemon mode',
type: 'checkbox'
},
]
const createCheckbox = (field) => {
const input = document.createElement('input');
input.setAttribute('type', 'checkbox');
input.setAttribute('name', field.id);
input.classList.add('w-4', 'h-4', 'text-blue-600', 'bg-gray-100', 'border-gray-300', 'rounded-sm', 'focus:ring-blue-500');
const labelCheckbox = document.createElement('label');
labelCheckbox.setAttribute('for', field.id);
labelCheckbox.classList.add('ms-2', 'text-sm', 'font-medium', 'text-gray-900', 'dark:text-white');
labelCheckbox.textContent = field.description;
const div = document.createElement('div');
div.classList.add('flex', 'items-center', 'mb-4');
div.appendChild(input);
div.appendChild(labelCheckbox);
return div;
}
const createInput = (field) => {
const input = document.getElementById('input-template').content.cloneNode(true);
input.querySelector('input').setAttribute('id', field.id);
input.querySelector('input').setAttribute('name', field.id);
input.querySelector('input').setAttribute('placeholder', field.placeholder);
const label = document.createElement('label');
label.setAttribute('for', field.id);
label.textContent = field.name;
label.classList.add('block', 'mb-2', 'text-sm', 'font-medium', 'text-gray-900', 'dark:text-white');
const div = document.createElement('div');
div.appendChild(label);
div.appendChild(input);
return div;
}
const createField = (field) => {
switch (field.type) {
case 'checkbox':
return createCheckbox(field);
case 'text':
return createInput(field);
}
}
window.onload = function () {
let startupForm = document.getElementById('startup-form-fields');
let buildForm = document.getElementById('build-form-fields');
const populateFormFields = (formElement, formFields) => {
formFields.forEach(field => formElement.appendChild(createField(field)));
};
populateFormFields(startupForm, startupFormFields);
populateFormFields(buildForm, buildFormFields);
};
function showTab(tabId) {
document.querySelectorAll('.tab-content').forEach(tab => {
tab.classList.add('hidden');
});
document.getElementById(tabId).classList.remove('hidden');
}
// Startup Form Handler
document.getElementById('startup-form').addEventListener('submit', function (event) {
event.preventDefault();
let command = 'unitd';
const formData = new FormData(this);
formData.forEach((value, key) => {
if (value) {
const option = key.replace('_', '-');
command += value === 'on' ? ` --${option}` : ` --${option}=${value}`;
}
});
document.getElementById('output-startup').value = command;
});
// Build Form Handler
document.getElementById('build-form').addEventListener('submit', function (event) {
event.preventDefault();
let command = './configure';
const formData = new FormData(this);
formData.forEach((value, key) => {
if (value) {
const option = key.replace('_', '-');
command += value === 'on' ? ` --${option}` : ` --${option}=${value}`;
}
});
document.getElementById('output-build').value = command.trim();
});
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": ["SoftwareApplication", "WebApplication"],
"name": "Unit Configurator",
"description": "An online tool for configuring Nginx Unit.",
"url": "https://nxunit.pavlusha.me",
"author": {
"@type": "Person",
"givenName": "Pavel",
"familyName": "Zavadski",
"url": "https://pavlusha.me",
"email":"[email protected]"
},
"publisher": {
"@type": "Person",
"givenName": "Pavel",
"familyName": "Zavadski",
"url": "https://pavlusha.me",
"email": "[email protected]"
},
"applicationCategory": "DeveloperApplication",
"operatingSystem": "All",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD",
"isAccessibleForFree": true
},
"softwareVersion": "0.1",
"datePublished": "2025-02-01",
"dateModified": "2025-02-01",
"sourceCode": {
"@type": "SoftwareSourceCode",
"programmingLanguage": "JSON",
"codeRepository": "https://github.com/pavlusha-unit-config/",
"keywords": [
"Nginx Unit Configuration",
"Unit Configurator",
"Nginx Deployment",
"Unit Application Configuration"
]
}
}
</script>
</body>
</html>