WIP: Traefik migration
This commit is contained in:
@@ -343,7 +343,7 @@ export async function startTraefikProxy(engine: string): Promise<void> {
|
|||||||
);
|
);
|
||||||
const ip = JSON.parse(Config)[0].Gateway;
|
const ip = JSON.parse(Config)[0].Gateway;
|
||||||
await asyncExecShell(
|
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.prisma.setting.update({ where: { id }, data: { proxyHash: null } });
|
||||||
await db.setDestinationSettings({ engine, isCoolifyProxyUsed: true });
|
await db.setDestinationSettings({ engine, isCoolifyProxyUsed: true });
|
||||||
|
|||||||
@@ -57,10 +57,14 @@ export default async function (): Promise<void | {
|
|||||||
if (destinationDockerId) {
|
if (destinationDockerId) {
|
||||||
if (destinationDocker.isCoolifyProxyUsed) {
|
if (destinationDocker.isCoolifyProxyUsed) {
|
||||||
if (settings.isTraefikUsed) {
|
if (settings.isTraefikUsed) {
|
||||||
await stopTcpHttpProxy(destinationDocker, ftpPublicPort, `${id}-ftp`);
|
await stopTcpHttpProxy(
|
||||||
|
destinationDocker,
|
||||||
|
ftpPublicPort,
|
||||||
|
`haproxy-for-${ftpPublicPort}`
|
||||||
|
);
|
||||||
await startTraefikTCPProxy(destinationDocker, `${id}-ftp`, ftpPublicPort, 22);
|
await startTraefikTCPProxy(destinationDocker, `${id}-ftp`, ftpPublicPort, 22);
|
||||||
} else {
|
} else {
|
||||||
await stopTcpHttpProxy(destinationDocker, ftpPublicPort, `${id}-ftp`);
|
await stopTcpHttpProxy(destinationDocker, ftpPublicPort, `proxy-for-${ftpPublicPort}`);
|
||||||
await startTcpProxy(destinationDocker, `${id}-ftp`, ftpPublicPort, 22);
|
await startTcpProxy(destinationDocker, `${id}-ftp`, ftpPublicPort, 22);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -210,7 +210,7 @@
|
|||||||
<div class="grid grid-flow-row gap-2 px-10">
|
<div class="grid grid-flow-row gap-2 px-10">
|
||||||
<!-- <Language /> -->
|
<!-- <Language /> -->
|
||||||
<div class="grid grid-cols-2 items-center">
|
<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="flex w-96 flex-col">
|
||||||
<div class="text-xs font-bold text-stone-100 md:text-base">New Proxy Available!</div>
|
<div class="text-xs font-bold text-stone-100 md:text-base">New Proxy Available!</div>
|
||||||
<Explainer
|
<Explainer
|
||||||
|
|||||||
@@ -14,28 +14,53 @@ export const get: RequestHandler = async (event) => {
|
|||||||
const type = event.url.searchParams.get('type');
|
const type = event.url.searchParams.get('type');
|
||||||
let traefik = {};
|
let traefik = {};
|
||||||
if (publicPort) {
|
if (publicPort) {
|
||||||
traefik = {
|
if (type === 'tcp') {
|
||||||
[type]: {
|
traefik = {
|
||||||
routers: {
|
[type]: {
|
||||||
[id]: {
|
routers: {
|
||||||
entrypoints: [type],
|
[id]: {
|
||||||
rule: `HostSNI(\`*\`)`,
|
entrypoints: [type],
|
||||||
service: id
|
rule: `HostSNI(\`*\`)`,
|
||||||
}
|
service: id
|
||||||
},
|
}
|
||||||
services: {
|
},
|
||||||
[id]: {
|
services: {
|
||||||
loadbalancer: {
|
[id]: {
|
||||||
servers: []
|
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') {
|
if (type === 'tcp') {
|
||||||
traefik[type].services[id].loadbalancer.servers.push({ address: `${id}:${privatePort}` });
|
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}` });
|
traefik[type].services[id].loadbalancer.servers.push({ url: `http://${id}:${privatePort}` });
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user