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

@ -1,5 +1,5 @@
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"; import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
import { InferSelectModel} from "drizzle-orm"; import { InferSelectModel } from "drizzle-orm";
export const orgs = sqliteTable("orgs", { export const orgs = sqliteTable("orgs", {
orgId: text("orgId").primaryKey(), orgId: text("orgId").primaryKey(),
@ -34,6 +34,7 @@ export const resources = sqliteTable("resources", {
}), }),
name: text("name").notNull(), name: text("name").notNull(),
subdomain: text("subdomain"), subdomain: text("subdomain"),
ssl: integer("ssl", { mode: "boolean" }).notNull().default(false),
}); });
export const targets = sqliteTable("targets", { export const targets = sqliteTable("targets", {
@ -46,7 +47,6 @@ export const targets = sqliteTable("targets", {
port: integer("port").notNull(), port: integer("port").notNull(),
protocol: text("protocol"), protocol: text("protocol"),
enabled: integer("enabled", { mode: "boolean" }).notNull().default(true), enabled: integer("enabled", { mode: "boolean" }).notNull().default(true),
ssl: integer("ssl", { mode: "boolean" }).notNull().default(false),
}); });
export const exitNodes = sqliteTable("exitNodes", { export const exitNodes = sqliteTable("exitNodes", {

View file

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