CI / go-test (push) Canceled after 0s
CI / postgres-durable-first (push) Canceled after 0s
CI / codegen (push) Canceled after 0s
CI / govulncheck (push) Canceled after 0s
CI / race (push) Canceled after 0s
CI / fuzz-smoke (push) Canceled after 0s
CI / golangci (push) Canceled after 0s
CI / frontend (push) Canceled after 0s
CodeQL Advanced / Analyze (go) (push) Canceled after 0s
CodeQL Advanced / Analyze (actions) (push) Canceled after 0s
CodeQL Advanced / Analyze (javascript-typescript) (push) Canceled after 0s
Docs CI / build (push) Canceled after 0s
Docs Deploy (GitHub Pages) / build (push) Canceled after 0s
Release 3X-UI / build (386) (push) Canceled after 0s
Release 3X-UI / build (amd64) (push) Canceled after 0s
Release 3X-UI / build (arm64) (push) Canceled after 0s
Release 3X-UI / build (armv5) (push) Canceled after 0s
Release 3X-UI / build (armv6) (push) Canceled after 0s
Release 3X-UI / build (armv7) (push) Canceled after 0s
Release 3X-UI / build (s390x) (push) Canceled after 0s
Release 3X-UI / Build for Windows (amd64) (push) Canceled after 0s
Deploy Smoke Tests / noninteractive-install (ubuntu-24.04-arm) (push) Canceled after 0s
Deploy Smoke Tests / noninteractive-install (ubuntu-latest) (push) Canceled after 0s
Deploy Smoke Tests / release-tag-install (ubuntu-24.04-arm) (push) Canceled after 0s
Deploy Smoke Tests / release-tag-install (ubuntu-latest) (push) Canceled after 0s
Docs Deploy (GitHub Pages) / deploy (push) Canceled after 0s
Release 3X-UI / Publish rolling dev release (push) Canceled after 0s
70 lines
2.3 KiB
TypeScript
70 lines
2.3 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import {
|
|
buildProxyConfig,
|
|
buildCertCommand,
|
|
type ProxyServer,
|
|
type CertTool,
|
|
type ReverseProxyOptions,
|
|
} from '@/lib/xray/reverse-proxy';
|
|
import { ToolFrame } from './tool-frame';
|
|
import { TextField, SelectField } from './shared/fields';
|
|
import { OutputBlock } from './shared/output-block';
|
|
|
|
export function ReverseProxyGenerator() {
|
|
const [server, setServer] = useState<ProxyServer>('nginx');
|
|
const [domain, setDomain] = useState('panel.example.com');
|
|
const [panelPort, setPanelPort] = useState('2053');
|
|
const [panelPath, setPanelPath] = useState('/panel');
|
|
const [certTool, setCertTool] = useState<CertTool>('certbot');
|
|
|
|
const options: ReverseProxyOptions = { server, domain, panelPort, panelPath, certTool };
|
|
|
|
return (
|
|
<ToolFrame
|
|
title="Reverse-proxy config generator"
|
|
description="Generate an Nginx or Caddy reverse-proxy config (with WebSocket support) and a matching certificate command."
|
|
>
|
|
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
|
<SelectField
|
|
label="Server"
|
|
value={server}
|
|
onChange={(v) => setServer(v as ProxyServer)}
|
|
options={['nginx', 'caddy']}
|
|
/>
|
|
<TextField label="Domain" value={domain} onChange={setDomain} />
|
|
<TextField
|
|
label="Panel port"
|
|
value={panelPort}
|
|
onChange={setPanelPort}
|
|
inputMode="numeric"
|
|
/>
|
|
<TextField label="Panel web base path" value={panelPath} onChange={setPanelPath} />
|
|
{server === 'nginx' ? (
|
|
<SelectField
|
|
label="Certificate tool"
|
|
value={certTool}
|
|
onChange={(v) => setCertTool(v as CertTool)}
|
|
options={['certbot', 'acme.sh']}
|
|
/>
|
|
) : null}
|
|
</div>
|
|
|
|
<div className="mt-4 grid grid-cols-1 gap-4">
|
|
<OutputBlock
|
|
label={server === 'nginx' ? 'nginx server block' : 'Caddyfile'}
|
|
value={buildProxyConfig(options)}
|
|
/>
|
|
{server === 'nginx' ? (
|
|
<OutputBlock label="Obtain a certificate" value={buildCertCommand(options)} />
|
|
) : (
|
|
<p className="text-sm text-fd-muted-foreground">
|
|
Caddy obtains and renews TLS certificates automatically — no extra command needed.
|
|
</p>
|
|
)}
|
|
</div>
|
|
</ToolFrame>
|
|
);
|
|
}
|