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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: Proxy for http
Andras Bacsaic0d711170bc2
diff --git a/src/lib/database/common.ts b/src/lib/database/common.tsindex 53551882bd..3196a40ee8 100644--- a/src/lib/database/common.ts+++ b/src/lib/database/common.ts@@ -305,6 +305,12 @@ export async function getFreePort() {select: { mysqlPublicPort: true }})).map((a) => a.mysqlPublicPort);- const usedPorts = [...dbUsed, ...wpFtpUsed, ...wpUsed];+ const minioUSed = await (+ await prisma.minio.findMany({+ where: { publicPort: { not: null } },+ select: { publicPort: true }+ })+ ).map((a) => a.publicPort);+ const usedPorts = [...dbUsed, ...wpFtpUsed, ...wpUsed, ...minioUSed];return await getPort({ port: portNumbers(minPort, maxPort), exclude: usedPorts });}diff --git a/src/lib/haproxy/index.ts b/src/lib/haproxy/index.tsindex 5101862870..b9a8e95817 100644--- a/src/lib/haproxy/index.ts+++ b/src/lib/haproxy/index.ts@@ -202,8 +202,7 @@ export async function startTcpProxy(destinationDocker: DestinationDocker,id: string,publicPort: number,- privatePort: number,- volume?: string+ privatePort: number): Promise<{ stdout: string; stderr: string } | Error> {const { network, engine } = destinationDocker;const host = getEngine(engine);@@ -218,9 +217,7 @@ export async function startTcpProxy();const ip = JSON.parse(Config)[0].Gateway;return await asyncExecShell(- `DOCKER_HOST=${host} docker run --restart always -e PORT=${publicPort} -e APP=${id} -e PRIVATE_PORT=${privatePort} --add-host 'host.docker.internal:host-gateway' --add-host 'host.docker.internal:${ip}' --network ${network} -p ${publicPort}:${publicPort} --name ${containerName} ${- volume ? `-v ${volume}` : ''- } -d coollabsio/${defaultProxyImageTcp}`+ `DOCKER_HOST=${host} docker run --restart always -e PORT=${publicPort} -e APP=${id} -e PRIVATE_PORT=${privatePort} --add-host 'host.docker.internal:host-gateway' --add-host 'host.docker.internal:${ip}' --network ${network} -p ${publicPort}:${publicPort} --name ${containerName} -d coollabsio/${defaultProxyImageTcp}`);}if (!foundDependentContainer && found) {@@ -262,11 +259,15 @@ export async function startTraefikHTTPProxy(`--entrypoints.http.address=:${publicPort}`,`--providers.http.endpoint=${otherTraefikEndpoint}?id=${id}&privatePort=${privatePort}&publicPort=${publicPort}&type=http`,'--providers.http.pollTimeout=2s',+ '--certificatesresolvers.letsencrypt.acme.httpchallenge=true',+ '--certificatesresolvers.letsencrypt.acme.storage=/etc/traefik/acme/acme.json',+ '--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=http','--log.level=error'],ports: [`${publicPort}:${publicPort}`],extra_hosts: ['host.docker.internal:host-gateway', `host.docker.internal:${ip}`],- networks: ['coolify-infra', network]+ networks: ['coolify-infra', network],+ volumes: ['coolify-traefik-letsencrypt:/etc/traefik/acme']}},networks: {@@ -278,6 +279,9 @@ export async function startTraefikHTTPProxy(external: false,name: 'coolify-infra'}+ },+ volumes: {+ 'coolify-traefik-letsencrypt': {}}};await fs.writeFile(`/tmp/docker-compose-${id}.yaml`, yaml.dump(tcpProxy));diff --git a/src/lib/queues/proxyTcpHttp.ts b/src/lib/queues/proxyTcpHttp.tsindex c70339bad0..4d5f3ec290 100644--- a/src/lib/queues/proxyTcpHttp.ts+++ b/src/lib/queues/proxyTcpHttp.ts@@ -85,6 +85,7 @@ export default async function (): Promise<void | {where: { publicPort: { not: null } },include: { service: { include: { destinationDocker: true } } }});+ console.log(minioInstances);for (const minio of minioInstances) {const { service, publicPort } = minio;const { destinationDockerId, destinationDocker, id } = service;@@ -101,6 +102,7 @@ export default async function (): Promise<void | {}}} catch (error) {+ console.log(error);return ErrorHandler(error.response?.body || error);}}diff --git a/src/routes/services/[id]/minio/stop.json.ts b/src/routes/services/[id]/minio/stop.json.tsindex 3e23402379..4ae3c106b8 100644--- a/src/routes/services/[id]/minio/stop.json.ts+++ b/src/routes/services/[id]/minio/stop.json.ts@@ -12,12 +12,7 @@ export const post: RequestHandler = async (event) => {try {const service = await db.getService({ id, teamId });- const {- destinationDockerId,- destinationDocker,- fqdn,- minio: { publicPort }- } = service;+ const { destinationDockerId, destinationDocker } = service;await db.updateMinioService({ id, publicPort: null });if (destinationDockerId) {const engine = destinationDocker.engine;@@ -30,11 +25,6 @@ export const post: RequestHandler = async (event) => {} catch (error) {console.error(error);}- try {- await stopTcpHttpProxy(destinationDocker, publicPort);- } catch (error) {- console.log(error);- }}return {diff --git a/src/routes/webhooks/traefik/other.json.ts b/src/routes/webhooks/traefik/other.json.tsindex ea99e770eb..428c9e2172 100644--- a/src/routes/webhooks/traefik/other.json.ts+++ b/src/routes/webhooks/traefik/other.json.ts@@ -37,6 +37,7 @@ export const get: RequestHandler = async (event) => {const service = await db.prisma.service.findFirst({ where: { id } });if (service?.fqdn) {const domain = getDomain(service.fqdn);+ const isHttps = service.fqdn.startsWith('https://');traefik = {[type]: {routers: {@@ -55,6 +56,19 @@ export const get: RequestHandler = async (event) => {}}};+ if (isHttps) {+ if (dev) {+ traefik[type].routers[id].tls = {+ domains: {+ main: `${domain}`+ }+ };+ } else {+ traefik[type].routers[id].tls = {+ certresolver: 'letsencrypt'+ };+ }+ }}}}