Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

WIP: Traefik migration

Andras Bacsai1fa5c5e0213b
diff --git a/src/lib/haproxy/index.ts b/src/lib/haproxy/index.ts
index 77a61974ed..8f7d595920 100644
--- a/src/lib/haproxy/index.ts
+++ b/src/lib/haproxy/index.ts
@@ -343,7 +343,7 @@ export async function startTraefikProxy(engine: string): Promise<void> {
);
const ip = JSON.parse(Config)[0].Gateway;
await asyncExecShell(
- `DOCKER_HOST="${host}" docker run --restart always --label "traefik.http.middlewares.dashboard.basicauth.users=${proxyUser}:${proxyPassword}" --label "traefik.http.routers.dashboard.service=api@internal" --label "traefik.http.routers.dashboard.middlewares=auth" --add-host 'host.docker.internal:host-gateway' --add-host 'host.docker.internal:${ip}' -v coolify-ssl-certs:/usr/local/etc/haproxy/ssl -v /var/run/docker.sock:/var/run/docker.sock --network coolify-infra -p "80:80" -p "443:443" -p "8080:8080" --name coolify-proxy -d ${defaultTraefikImage} --api.dashboard=true --entrypoints.web.address=:80 --entrypoints.websecure.address=:443 --providers.docker=false --providers.docker.exposedbydefault=false --providers.http.endpoint=${coolifyEndpoint} --providers.http.pollTimeout=5s --log.level=error`
+ `DOCKER_HOST="${host}" docker run --restart always --add-host 'host.docker.internal:host-gateway' --add-host 'host.docker.internal:${ip}' -v coolify-ssl-certs:/usr/local/etc/haproxy/ssl -v /var/run/docker.sock:/var/run/docker.sock --network coolify-infra -p "80:80" -p "443:443" -p "8080:8080" --name coolify-proxy -d ${defaultTraefikImage} --entrypoints.web.address=:80 --entrypoints.websecure.address=:443 --providers.docker=true --providers.docker.exposedbydefault=false --providers.http.endpoint=${coolifyEndpoint} --providers.http.pollTimeout=5s --log.level=error`
);
await db.prisma.setting.update({ where: { id }, data: { proxyHash: null } });
await db.setDestinationSettings({ engine, isCoolifyProxyUsed: true });
diff --git a/src/lib/queues/proxyTcpHttp.ts b/src/lib/queues/proxyTcpHttp.ts
index b23b1119f3..b120c2f745 100644
--- a/src/lib/queues/proxyTcpHttp.ts
+++ b/src/lib/queues/proxyTcpHttp.ts
@@ -57,10 +57,14 @@ export default async function (): Promise<void | {
if (destinationDockerId) {
if (destinationDocker.isCoolifyProxyUsed) {
if (settings.isTraefikUsed) {
- await stopTcpHttpProxy(destinationDocker, ftpPublicPort, `${id}-ftp`);
+ await stopTcpHttpProxy(
+ destinationDocker,
+ ftpPublicPort,
+ `haproxy-for-${ftpPublicPort}`
+ );
await startTraefikTCPProxy(destinationDocker, `${id}-ftp`, ftpPublicPort, 22);
} else {
- await stopTcpHttpProxy(destinationDocker, ftpPublicPort, `${id}-ftp`);
+ await stopTcpHttpProxy(destinationDocker, ftpPublicPort, `proxy-for-${ftpPublicPort}`);
await startTcpProxy(destinationDocker, `${id}-ftp`, ftpPublicPort, 22);
}
}
diff --git a/src/routes/settings/index.svelte b/src/routes/settings/index.svelte
index 9b97570a06..8c975d2a92 100644
--- a/src/routes/settings/index.svelte
+++ b/src/routes/settings/index.svelte
@@ -210,7 +210,7 @@
<div class="grid grid-flow-row gap-2 px-10">
<!-- <Language /> -->
<div class="grid grid-cols-2 items-center">
- <div class="flex items-center py-4 pr-8">
+ <div class="flex items-center py-2 pr-8">
<div class="flex w-96 flex-col">
<div class="text-xs font-bold text-stone-100 md:text-base">New Proxy Available!</div>
<Explainer
diff --git a/src/routes/traefik.json.ts b/src/routes/traefik.json.ts
index d14438d9e7..5f7a5934fd 100644
--- a/src/routes/traefik.json.ts
+++ b/src/routes/traefik.json.ts
@@ -14,28 +14,53 @@ export const get: RequestHandler = async (event) => {
const type = event.url.searchParams.get('type');
let traefik = {};
if (publicPort) {
- traefik = {
- [type]: {
- routers: {
- [id]: {
- entrypoints: [type],
- rule: `HostSNI(\`*\`)`,
- service: id
- }
- },
- services: {
- [id]: {
- loadbalancer: {
- servers: []
+ if (type === 'tcp') {
+ traefik = {
+ [type]: {
+ routers: {
+ [id]: {
+ entrypoints: [type],
+ rule: `HostSNI(\`*\`)`,
+ service: id
+ }
+ },
+ services: {
+ [id]: {
+ loadbalancer: {
+ servers: []
+ }
}
}
}
+ };
+ } else if (type === 'http') {
+ const service = await db.prisma.service.findFirst({ where: { id } });
+ if (service?.fqdn) {
+ const domain = getDomain(service.fqdn);
+ traefik = {
+ [type]: {
+ routers: {
+ [id]: {
+ entrypoints: [type],
+ rule: `Host(\`${domain}\`)`,
+ service: id
+ }
+ },
+ services: {
+ [id]: {
+ loadbalancer: {
+ servers: []
+ }
+ }
+ }
+ }
+ };
}
- };
+ }
}
if (type === 'tcp') {
traefik[type].services[id].loadbalancer.servers.push({ address: `${id}:${privatePort}` });
- } else {
+ } else if (type === 'http') {
traefik[type].services[id].loadbalancer.servers.push({ url: `http://${id}:${privatePort}` });
}
return {