move ssl from target to resource

This commit is contained in:
Milo Schwartz 2024-10-28 23:34:04 -04:00
parent e279d93570
commit 1fb43a5ce4
No known key found for this signature in database
2 changed files with 7 additions and 7 deletions

View file

@ -34,6 +34,7 @@ export const resources = sqliteTable("resources", {
}),
name: text("name").notNull(),
subdomain: text("subdomain"),
ssl: integer("ssl", { mode: "boolean" }).notNull().default(false),
});
export const targets = sqliteTable("targets", {
@ -46,7 +47,6 @@ export const targets = sqliteTable("targets", {
port: integer("port").notNull(),
protocol: text("protocol"),
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
ssl: integer("ssl", { mode: "boolean" }).notNull().default(false),
});
export const exitNodes = sqliteTable("exitNodes", {

View file

@ -82,7 +82,7 @@ export async function traefikConfigProvider(
? {
domains: [
{
main: wildCard
main: wildCard,
},
],
}
@ -91,17 +91,17 @@ export async function traefikConfigProvider(
http.routers![routerName] = {
entryPoints: [
target.ssl
resource.ssl
? config.traefik.https_entrypoint
: config.traefik.http_entrypoint,
],
middlewares: target.ssl ? [badgerMiddlewareName] : [],
middlewares: resource.ssl ? [badgerMiddlewareName] : [],
service: serviceName,
rule: `Host(\`${resource.fullDomain}\`)`,
...(target.ssl ? { tls } : {}),
...(resource.ssl ? { tls } : {}),
};
if (target.ssl) {
if (resource.ssl) {
// this is a redirect router; all it does is redirect to the https version if tls is enabled
http.routers![routerName + "-redirect"] = {
entryPoints: [config.traefik.http_entrypoint],