mirror of
https://github.com/tale/headplane.git
synced 2026-08-31 17:28:14 +00:00
feat: allow a public headscale URL separate from the main one
This commit is contained in:
@@ -46,6 +46,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|||||||
users: users.users,
|
users: users.users,
|
||||||
magic,
|
magic,
|
||||||
server: context.headscaleUrl,
|
server: context.headscaleUrl,
|
||||||
|
publicServer: context.headscalePublicUrl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +74,10 @@ export default function Page() {
|
|||||||
</Link>
|
</Link>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<NewMachine server={data.server} users={data.users} />
|
<NewMachine
|
||||||
|
server={data.publicServer ?? data.server}
|
||||||
|
users={data.users}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<table className="table-auto w-full rounded-lg">
|
<table className="table-auto w-full rounded-lg">
|
||||||
<thead className="text-gray-500 dark:text-gray-400">
|
<thead className="text-gray-500 dark:text-gray-400">
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|||||||
return {
|
return {
|
||||||
keys: preAuthKeys.flatMap(keys => keys.preAuthKeys),
|
keys: preAuthKeys.flatMap(keys => keys.preAuthKeys),
|
||||||
users: users.users,
|
users: users.users,
|
||||||
server: context.headscaleUrl,
|
server: context.headscalePublicUrl ?? context.headscaleUrl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import log from '~/utils/log'
|
|||||||
export interface HeadplaneContext {
|
export interface HeadplaneContext {
|
||||||
debug: boolean
|
debug: boolean
|
||||||
headscaleUrl: string
|
headscaleUrl: string
|
||||||
|
headscalePublicUrl?: string
|
||||||
cookieSecret: string
|
cookieSecret: string
|
||||||
integration: IntegrationFactory | undefined
|
integration: IntegrationFactory | undefined
|
||||||
|
|
||||||
@@ -56,12 +57,18 @@ export async function loadContext(): Promise<HeadplaneContext> {
|
|||||||
const { config, contextData } = await checkConfig(path)
|
const { config, contextData } = await checkConfig(path)
|
||||||
|
|
||||||
let headscaleUrl = process.env.HEADSCALE_URL
|
let headscaleUrl = process.env.HEADSCALE_URL
|
||||||
|
let headscalePublicUrl = process.env.HEADSCALE_PUBLIC_URL
|
||||||
|
|
||||||
if (!headscaleUrl && !config) {
|
if (!headscaleUrl && !config) {
|
||||||
throw new Error('HEADSCALE_URL not set')
|
throw new Error('HEADSCALE_URL not set')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config) {
|
if (config) {
|
||||||
headscaleUrl = headscaleUrl ?? config.server_url
|
headscaleUrl = headscaleUrl ?? config.server_url
|
||||||
|
if (!headscalePublicUrl) {
|
||||||
|
// Fallback to the config value if the env var is not set
|
||||||
|
headscalePublicUrl = config.public_url
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!headscaleUrl) {
|
if (!headscaleUrl) {
|
||||||
@@ -76,6 +83,7 @@ export async function loadContext(): Promise<HeadplaneContext> {
|
|||||||
context = {
|
context = {
|
||||||
debug,
|
debug,
|
||||||
headscaleUrl,
|
headscaleUrl,
|
||||||
|
headscalePublicUrl,
|
||||||
cookieSecret,
|
cookieSecret,
|
||||||
integration: await loadIntegration(),
|
integration: await loadIntegration(),
|
||||||
config: contextData,
|
config: contextData,
|
||||||
@@ -84,6 +92,10 @@ export async function loadContext(): Promise<HeadplaneContext> {
|
|||||||
|
|
||||||
log.info('CTXT', 'Starting Headplane with Context')
|
log.info('CTXT', 'Starting Headplane with Context')
|
||||||
log.info('CTXT', 'HEADSCALE_URL: %s', headscaleUrl)
|
log.info('CTXT', 'HEADSCALE_URL: %s', headscaleUrl)
|
||||||
|
if (headscalePublicUrl) {
|
||||||
|
log.info('CTXT', 'HEADSCALE_PUBLIC_URL: %s', headscalePublicUrl)
|
||||||
|
}
|
||||||
|
|
||||||
log.info('CTXT', 'Integration: %s', context.integration?.name ?? 'None')
|
log.info('CTXT', 'Integration: %s', context.integration?.name ?? 'None')
|
||||||
log.info('CTXT', 'Config: %s', contextData.read
|
log.info('CTXT', 'Config: %s', contextData.read
|
||||||
? `Found ${contextData.write ? '' : '(Read Only)'}`
|
? `Found ${contextData.write ? '' : '(Read Only)'}`
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ You can configure Headplane using environment variables.
|
|||||||
|
|
||||||
#### Optional Variables
|
#### Optional Variables
|
||||||
|
|
||||||
|
- **`HEADSCALE_PUBLIC_URL`**: The public URL of your Headscale server (if different from `HEADSCALE_URL`).
|
||||||
- **`DEBUG`**: Enable debug logging (default: `false`).
|
- **`DEBUG`**: Enable debug logging (default: `false`).
|
||||||
- **`HOST`**: The host to bind the server to (default: `0.0.0.0`).
|
- **`HOST`**: The host to bind the server to (default: `0.0.0.0`).
|
||||||
- **`PORT`**: The port to bind the server to (default: `3000`).
|
- **`PORT`**: The port to bind the server to (default: `3000`).
|
||||||
|
|||||||
Reference in New Issue
Block a user