diff --git a/package.json b/package.json
index 158b144cf..1729674ed 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "coolify",
"description": "An open-source & self-hostable Heroku / Netlify alternative.",
- "version": "2.0.6",
+ "version": "2.0.7",
"license": "AGPL-3.0",
"scripts": {
"dev": "docker compose -f docker-compose-dev.yaml up -d && NODE_ENV=development svelte-kit dev --host 0.0.0.0",
@@ -17,7 +17,8 @@
"db:push": "prisma db push && prisma generate",
"db:seed": "prisma db seed",
"release:staging": "cross-var docker build -t coollabsio/coolify:$npm_package_version . && docker push coollabsio/coolify:$npm_package_version",
- "release:coolify": "cross-var yarn prerelease && docker push coollabsio/coolify:$npm_package_version && docker image push coollabsio/coolify:$npm_package_version && docker push coollabsio/coolify:latest",
+ "release:pre": "cross-var docker build -t coollabsio/coolify:$npm_package_version -t coollabsio/coolify:latest .",
+ "release:coolify": "cross-var yarn release:pre && docker push coollabsio/coolify:$npm_package_version && docker push coollabsio/coolify:latest",
"release:haproxy": "docker build -f haproxy.Dockerfile -t coollabsio/coolify-haproxy-alpine:1.0.0 -t coollabsio/coolify-haproxy-alpine:latest . && docker image push --all-tags coollabsio/coolify-haproxy-alpine",
"release:haproxy:tcp": "docker build -f haproxy-tcp.Dockerfile -t coollabsio/coolify-haproxy-tcp-alpine:1.0.0 -t coollabsio/coolify-haproxy-tcp-alpine:latest . && docker image push --all-tags coollabsio/coolify-haproxy-tcp-alpine",
"release:haproxy:http": "docker build -f haproxy-http.Dockerfile -t coollabsio/coolify-haproxy-http-alpine:1.0.0 -t coollabsio/coolify-haproxy-http-alpine:latest . && docker image push --all-tags coollabsio/coolify-haproxy-http-alpine",
diff --git a/src/lib/common.ts b/src/lib/common.ts
index 70fd7eeba..b4b6966bc 100644
--- a/src/lib/common.ts
+++ b/src/lib/common.ts
@@ -67,7 +67,6 @@ export const getTeam = (event) => {
};
export const getUserDetails = async (event, isAdminRequired = true) => {
- // try {
const teamId = getTeam(event);
const userId = event.locals.session.data.uid || null;
const { permission = 'read' } = await db.prisma.permission.findFirst({
@@ -91,18 +90,6 @@ export const getUserDetails = async (event, isAdminRequired = true) => {
}
return payload;
- // } catch (err) {
- // console.log(err);
- // return {
- // teamId: null,
- // userId: null,
- // permission: 'read',
- // status: 401,
- // body: {
- // message: 'You do not have permission to do this. \nAsk an admin to modify your permissions.'
- // }
- // };
- // }
};
export function getEngine(engine) {
diff --git a/src/lib/components/CopyPasswordField.svelte b/src/lib/components/CopyPasswordField.svelte
index 4237f6e8e..ab43f48bd 100644
--- a/src/lib/components/CopyPasswordField.svelte
+++ b/src/lib/components/CopyPasswordField.svelte
@@ -20,9 +20,6 @@
function showActions(value) {
actionsShow = value;
- // if (value === false) {
- // showPassword = false;
- // }
}
function copyToClipboard() {
if (isHttps && navigator.clipboard) {
diff --git a/src/lib/components/Setting.svelte b/src/lib/components/Setting.svelte
index 4a80e56ae..b26e3e072 100644
--- a/src/lib/components/Setting.svelte
+++ b/src/lib/components/Setting.svelte
@@ -6,7 +6,6 @@
export let description;
export let isPadding = true;
export let disabled = false;
- // export let disabledReason = '';
@@ -14,11 +13,6 @@
{title}
-
0) {
- const rule = rules.data.find((rule) => rule.cond_test.includes(`-i ${domain}`));
+ const rule = rules.data.find((rule) =>
+ rule.cond_test.includes(`{ hdr(host) -i ${domain} } !{ ssl_fc }`)
+ );
if (rule) return;
nextRule = rules.data[rules.data.length - 1].index + 1;
}
@@ -138,7 +141,7 @@ export async function forceSSLOnApplication({ domain }) {
json: {
index: nextRule,
cond: 'if',
- cond_test: `{ hdr(Host) -i ${domain} } !{ ssl_fc }`,
+ cond_test: `{ hdr(host) -i ${domain} } !{ ssl_fc }`,
type: 'redirect',
redir_type: 'scheme',
redir_value: 'https',
@@ -188,94 +191,7 @@ export async function deleteProxy({ id }) {
await completeTransaction(transactionId);
}
}
-// export async function configureProxyForDatabase({ id, port, isPublic, privatePort }) {
-// const haproxy = await haproxyInstance()
-// try {
-// await checkHAProxy()
-// } catch (error) {
-// return
-// }
-// let alreadyConfigured = false
-// try {
-// const backend: any = await haproxy.get(`v2/services/haproxy/configuration/backends/${id}`).json()
-// const server: any = await haproxy.get(`v2/services/haproxy/configuration/servers/${id}`, {
-// searchParams: {
-// backend: id
-// },
-// }).json()
-// if (backend.data.name === id) {
-// if (server.data.port === privatePort) {
-// if (server.data.check === 'enabled') {
-// if (server.data.address === id) {
-// alreadyConfigured = true
-// }
-// }
-// }
-// }
-// } catch (error) {
-// console.log('error getting backend or server', error.response.body)
-// }
-// if (alreadyConfigured) return
-
-// const transactionId = await getNextTransactionId()
-// try {
-// await haproxy.post('v2/services/haproxy/configuration/backends', {
-// searchParams: {
-// transaction_id: transactionId
-// },
-// json: {
-// "init-addr": "last,libc,none",
-// "mode": "tcp",
-// "name": id
-// }
-// })
-// await haproxy.post('v2/services/haproxy/configuration/servers', {
-// searchParams: {
-// transaction_id: transactionId,
-// backend: id
-// },
-// json: {
-// "address": id,
-// "check": "enabled",
-// "name": id,
-// "port": privatePort
-// }
-// })
-// await haproxy.post('v2/services/haproxy/configuration/frontends', {
-// searchParams: {
-// transaction_id: transactionId,
-// backend: id
-// },
-// json: {
-// "default_backend": id,
-// "mode": "tcp",
-// "name": id
-// }
-// })
-// await haproxy.post('v2/services/haproxy/configuration/binds', {
-// searchParams: {
-// transaction_id: transactionId,
-// frontend: id
-// },
-// json: {
-// "address": "*",
-// "name": id,
-// "port": port
-// }
-// })
-// } catch (error) {
-// console.log(error.response.body)
-// throw error.response.body
-// } finally {
-// try {
-// await completeTransaction(transactionId)
-// } catch (error) {
-// console.log(error.response.body)
-// }
-// }
-// await configureDatabaseVisibility({ id, isPublic })
-// }
export async function reloadHaproxy(engine) {
const host = getEngine(engine);
return await asyncExecShell(`DOCKER_HOST=${host} docker exec coolify-haproxy kill -HUP 1`);
@@ -364,7 +280,8 @@ export async function configureProxyForApplication({ domain, imageId, applicatio
}
}
-export async function configureCoolifyProxyOff({ domain }) {
+export async function configureCoolifyProxyOff(fqdn) {
+ const domain = getDomain(fqdn);
const haproxy = await haproxyInstance();
try {
await checkHAProxy(haproxy);
@@ -386,6 +303,7 @@ export async function configureCoolifyProxyOff({ domain }) {
if (!dev) {
await forceSSLOffApplication({ domain });
}
+ await setWwwRedirection(fqdn);
} catch (error) {
throw error?.response?.body || error;
}
@@ -398,7 +316,8 @@ export async function checkHAProxy(haproxy) {
throw 'HAProxy is not running, but it should be!';
}
}
-export async function configureCoolifyProxyOn({ domain }) {
+export async function configureCoolifyProxyOn(fqdn) {
+ const domain = getDomain(fqdn);
const haproxy = await haproxyInstance();
try {
await checkHAProxy(haproxy);
@@ -605,7 +524,15 @@ export async function configureSimpleServiceProxyOn({ id, domain, port }) {
await checkHAProxy(haproxy);
try {
await haproxy.get(`v2/services/haproxy/configuration/backends/${domain}`).json();
- return;
+ const transactionId = await getNextTransactionId();
+ await haproxy
+ .delete(`v2/services/haproxy/configuration/backends/${domain}`, {
+ searchParams: {
+ transaction_id: transactionId
+ }
+ })
+ .json();
+ await completeTransaction(transactionId);
} catch (error) {}
try {
const transactionId = await getNextTransactionId();
@@ -631,6 +558,12 @@ export async function configureSimpleServiceProxyOn({ id, domain, port }) {
port: port
}
});
+ console.log({
+ address: id,
+ check: 'enabled',
+ name: id,
+ port: port
+ });
await completeTransaction(transactionId);
} catch (error) {
console.log(error);
@@ -657,5 +590,98 @@ export async function configureSimpleServiceProxyOff({ domain }) {
.json();
await completeTransaction(transactionId);
} catch (error) {}
+ await removeWwwRedirection(domain);
return;
}
+
+export async function removeWwwRedirection(domain) {
+ const haproxy = await haproxyInstance();
+ try {
+ await checkHAProxy(haproxy);
+ } catch (error) {
+ return;
+ }
+
+ const rules: any = await haproxy
+ .get(`v2/services/haproxy/configuration/http_request_rules`, {
+ searchParams: {
+ parent_name: 'http',
+ parent_type: 'frontend'
+ }
+ })
+ .json();
+ if (rules.data.length > 0) {
+ const rule = rules.data.find((rule) =>
+ rule.redir_value.includes(`${domain}%[capture.req.uri]`)
+ );
+ if (rule) {
+ const transactionId = await getNextTransactionId();
+ await haproxy
+ .delete(`v2/services/haproxy/configuration/http_request_rules/${rule.index}`, {
+ searchParams: {
+ transaction_id: transactionId,
+ parent_name: 'http',
+ parent_type: 'frontend'
+ }
+ })
+ .json();
+ await completeTransaction(transactionId);
+ }
+ }
+}
+export async function setWwwRedirection(fqdn) {
+ const haproxy = await haproxyInstance();
+ try {
+ await checkHAProxy(haproxy);
+ } catch (error) {
+ return;
+ }
+ const transactionId = await getNextTransactionId();
+
+ try {
+ const domain = getDomain(fqdn);
+ const isHttps = fqdn.startsWith('https://');
+ const isWWW = fqdn.includes('www.');
+ const contTest = `{ req.hdr(host) -i ${isWWW ? domain.replace('www.', '') : `www.${domain}`} }`;
+ const rules: any = await haproxy
+ .get(`v2/services/haproxy/configuration/http_request_rules`, {
+ searchParams: {
+ parent_name: 'http',
+ parent_type: 'frontend'
+ }
+ })
+ .json();
+ let nextRule = 0;
+ if (rules.data.length > 0) {
+ const rule = rules.data.find((rule) =>
+ rule.redir_value.includes(`${domain}%[capture.req.uri]`)
+ );
+ if (rule) return;
+ nextRule = rules.data[rules.data.length - 1].index + 1;
+ }
+ const redirectValue = `${isHttps ? 'https://' : 'http://'}${domain}%[capture.req.uri]`;
+ await haproxy
+ .post(`v2/services/haproxy/configuration/http_request_rules`, {
+ searchParams: {
+ transaction_id: transactionId,
+ parent_name: 'http',
+ parent_type: 'frontend'
+ },
+ json: {
+ index: nextRule,
+ cond: 'if',
+ cond_test: contTest,
+ type: 'redirect',
+ redir_type: 'location',
+ redir_value: redirectValue,
+ redir_code: dev ? 302 : 301
+ }
+ })
+ .json();
+ } catch (error) {
+ console.log(error);
+ throw error;
+ } finally {
+ await completeTransaction(transactionId);
+ }
+}
diff --git a/src/lib/queues/builder.ts b/src/lib/queues/builder.ts
index aba494d92..41b11dc1e 100644
--- a/src/lib/queues/builder.ts
+++ b/src/lib/queues/builder.ts
@@ -4,7 +4,7 @@ import * as buildpacks from '../buildPacks';
import * as importers from '../importers';
import { dockerInstance } from '../docker';
import { asyncExecShell, createDirectories, getDomain, getEngine, saveBuildLog } from '../common';
-import { configureProxyForApplication, reloadHaproxy } from '../haproxy';
+import { configureProxyForApplication, reloadHaproxy, setWwwRedirection } from '../haproxy';
import * as db from '$lib/database';
import { decrypt } from '$lib/crypto';
import { sentry } from '$lib/common';
@@ -64,10 +64,6 @@ export default async function (job) {
if (destinationDockerId) {
destinationType = 'docker';
}
- // Not implemented yet
- // if (destinationKubernetesId) {
- // destinationType = 'kubernetes'
- // }
if (destinationType === 'docker') {
const docker = dockerInstance({ destinationDocker });
@@ -209,9 +205,7 @@ export default async function (job) {
const envs = [];
if (secrets.length > 0) {
secrets.forEach((secret) => {
- if (!secret.isBuildSecret) {
- envs.push(`${secret.name}=${secret.value}`);
- }
+ envs.push(`${secret.name}=${secret.value}`);
});
}
await fs.writeFile(`${workdir}/.env`, envs.join('\n'));
@@ -252,6 +246,7 @@ export default async function (job) {
saveBuildLog({ line: 'Proxy configuration started!', buildId, applicationId });
await configureProxyForApplication({ domain, imageId, applicationId, port });
if (isHttps) await letsEncrypt({ domain, id: applicationId });
+ await setWwwRedirection(fqdn);
await reloadHaproxy(destinationDocker.engine);
saveBuildLog({ line: 'Proxy configuration successful!', buildId, applicationId });
} else {
diff --git a/src/lib/queues/index.ts b/src/lib/queues/index.ts
index e1889bd4f..ebe154051 100644
--- a/src/lib/queues/index.ts
+++ b/src/lib/queues/index.ts
@@ -144,28 +144,6 @@ buildWorker.on('failed', async (job: Bullmq.Job, failedReason) => {
});
});
-// const letsEncryptQueueName = dev ? cuid() : 'letsencrypt_queue'
-// const letsEncryptQueue = new Queue(letsEncryptQueueName, connectionOptions)
-
-// const letsEncryptWorker = new Worker(letsEncryptQueueName, async (job) => await letsencrypt(job), {
-// concurrency: 1,
-// ...connectionOptions
-// })
-// letsEncryptWorker.on('completed', async () => {
-// // TODO: Save letsencrypt logs as build logs!
-// console.log('[DEBUG] Lets Encrypt job completed')
-// })
-
-// letsEncryptWorker.on('failed', async (job: Job, failedReason: string) => {
-// try {
-// await prisma.applicationSettings.updateMany({ where: { applicationId: job.data.id }, data: { forceSSL: false } })
-// } catch (error) {
-// console.log(error)
-// }
-// console.log('[DEBUG] Lets Encrypt job failed')
-// console.log(failedReason)
-// })
-
const buildLogQueueName = dev ? cuid() : 'log_queue';
const buildLogQueue = new Queue(buildLogQueueName, connectionOptions);
const buildLogWorker = new Worker(buildLogQueueName, async (job) => await logger(job), {
diff --git a/src/lib/queues/proxy.ts b/src/lib/queues/proxy.ts
index 90dedde80..1e1b9c2f3 100644
--- a/src/lib/queues/proxy.ts
+++ b/src/lib/queues/proxy.ts
@@ -7,6 +7,7 @@ import {
configureProxyForApplication,
forceSSLOnApplication,
reloadHaproxy,
+ setWwwRedirection,
startCoolifyProxy
} from '$lib/haproxy';
import * as db from '$lib/database';
@@ -40,6 +41,7 @@ export default async function () {
});
const isHttps = fqdn.startsWith('https://');
if (isHttps) await forceSSLOnApplication({ domain });
+ await setWwwRedirection(fqdn);
}
}
}
@@ -52,6 +54,7 @@ export default async function () {
const found = await checkContainer('/var/run/docker.sock', 'coolify-haproxy');
if (!found) await startCoolifyProxy('/var/run/docker.sock');
await configureCoolifyProxyOn({ domain });
+ await setWwwRedirection(fqdn);
const isHttps = fqdn.startsWith('https://');
if (isHttps) await forceSSLOnApplication({ domain });
}
diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte
index fa9ce0fe3..d8e185a13 100644
--- a/src/routes/__layout.svelte
+++ b/src/routes/__layout.svelte
@@ -124,25 +124,6 @@
updateStatus.success = false;
updateStatus.loading = false;
}
- // } else {
- // let reachable = false;
- // let tries = 0;
- // do {
- // await asyncSleep(1000);
- // try {
- // await get(`/undead.json`);
- // reachable = true;
- // } catch (error) {
- // console.log(error);
- // reachable = false;
- // }
- // if (reachable) break;
- // tries++;
- // } while (!reachable || tries < 120);
- // toast.push('New version reachable. Reloading...');
- // await asyncSleep(2000);
- // window.location.reload();
- // }
}
diff --git a/src/routes/applications/[id]/configuration/_GitlabRepositories.svelte b/src/routes/applications/[id]/configuration/_GitlabRepositories.svelte
index a97291deb..fb1dd602b 100644
--- a/src/routes/applications/[id]/configuration/_GitlabRepositories.svelte
+++ b/src/routes/applications/[id]/configuration/_GitlabRepositories.svelte
@@ -142,14 +142,6 @@
return errorNotification('Branch already configured');
}
}
- // async function saveDeployKey(deployKeyId: number) {
- // try {
- // await post(updateDeployKeyIdUrl, { deployKeyId });
- // } catch (error) {
- // errorNotification(error);
- // throw new Error(error);
- // }
- // }
async function checkSSHKey(sshkeyUrl) {
try {
return await post(sshkeyUrl, {});
diff --git a/src/routes/applications/[id]/index.svelte b/src/routes/applications/[id]/index.svelte
index 91bc1c69f..930088ec5 100644
--- a/src/routes/applications/[id]/index.svelte
+++ b/src/routes/applications/[id]/index.svelte
@@ -266,7 +266,7 @@
required
/>
diff --git a/src/routes/applications/[id]/secrets/_Secret.svelte b/src/routes/applications/[id]/secrets/_Secret.svelte
index 90a1c2ffa..efe0b7c1a 100644
--- a/src/routes/applications/[id]/secrets/_Secret.svelte
+++ b/src/routes/applications/[id]/secrets/_Secret.svelte
@@ -18,6 +18,7 @@
if (isNewSecret) {
name = '';
value = '';
+ isBuildSecret = false;
}
} catch ({ error }) {
return errorNotification(error);
@@ -30,6 +31,7 @@
if (isNewSecret) {
name = '';
value = '';
+ isBuildSecret = false;
}
} catch ({ error }) {
return errorNotification(error);
diff --git a/src/routes/databases/[id]/index.json.ts b/src/routes/databases/[id]/index.json.ts
index 1f08ab7e6..c9867c94f 100644
--- a/src/routes/databases/[id]/index.json.ts
+++ b/src/routes/databases/[id]/index.json.ts
@@ -25,9 +25,7 @@ export const get: RequestHandler = async (event) => {
state = 'running';
}
} catch (error) {
- // if (!error.stderr.includes('No such object')) {
- // console.log(error)
- // }
+ //
}
}
const configuration = generateDatabaseConfiguration(database);
diff --git a/src/routes/services/[id]/_Services/_Services.svelte b/src/routes/services/[id]/_Services/_Services.svelte
index 0b1d6f622..6754d31fe 100644
--- a/src/routes/services/[id]/_Services/_Services.svelte
+++ b/src/routes/services/[id]/_Services/_Services.svelte
@@ -110,25 +110,9 @@
required
/>
-
{#if service.type === 'plausibleanalytics'}
diff --git a/src/routes/services/[id]/index.json.ts b/src/routes/services/[id]/index.json.ts
index eefed08b0..58f9beaef 100644
--- a/src/routes/services/[id]/index.json.ts
+++ b/src/routes/services/[id]/index.json.ts
@@ -46,24 +46,3 @@ export const get: RequestHandler = async (event) => {
return PrismaErrorHandler(error);
}
};
-
-// export const post: RequestHandler = async (request) => {
-// const { teamId, status, body } = await getUserDetails(request);
-// if (status === 401) return { status, body }
-// const { id } = request.params
-
-// const name = request.body.get('name')
-// const defaultDatabase = request.body.get('defaultDatabase')
-// const dbUser = request.body.get('dbUser')
-// const dbUserPassword = request.body.get('dbUserPassword')
-// const rootUser = request.body.get('rootUser')
-// const rootUserPassword = request.body.get('rootUserPassword')
-// const version = request.body.get('version')
-
-// try {
-// return await db.updateDatabase({ id, name, defaultDatabase, dbUser, dbUserPassword, rootUser, rootUserPassword, version })
-// } catch (err) {
-// return err
-// }
-
-// }
diff --git a/src/routes/services/[id]/minio/start.json.ts b/src/routes/services/[id]/minio/start.json.ts
index 3b7d78525..dbdf65613 100644
--- a/src/routes/services/[id]/minio/start.json.ts
+++ b/src/routes/services/[id]/minio/start.json.ts
@@ -7,6 +7,7 @@ import { letsEncrypt } from '$lib/letsencrypt';
import {
configureSimpleServiceProxyOn,
reloadHaproxy,
+ setWwwRedirection,
startHttpProxy,
startTcpProxy
} from '$lib/haproxy';
@@ -86,13 +87,13 @@ export const post: RequestHandler = async (event) => {
try {
await asyncExecShell(`DOCKER_HOST=${host} docker compose -f ${composeFileDestination} up -d`);
await configureSimpleServiceProxyOn({ id, domain, port: consolePort });
-
await db.updateMinioService({ id, publicPort });
await startHttpProxy(destinationDocker, id, publicPort, apiPort);
if (isHttps) {
await letsEncrypt({ domain, id });
}
+ await setWwwRedirection(fqdn);
await reloadHaproxy(destinationDocker.engine);
return {
status: 200
diff --git a/src/routes/services/[id]/nocodb/start.json.ts b/src/routes/services/[id]/nocodb/start.json.ts
index 6d7d214a8..b0e29457c 100644
--- a/src/routes/services/[id]/nocodb/start.json.ts
+++ b/src/routes/services/[id]/nocodb/start.json.ts
@@ -4,7 +4,7 @@ import { promises as fs } from 'fs';
import yaml from 'js-yaml';
import type { RequestHandler } from '@sveltejs/kit';
import { letsEncrypt } from '$lib/letsencrypt';
-import { configureSimpleServiceProxyOn, reloadHaproxy } from '$lib/haproxy';
+import { configureSimpleServiceProxyOn, reloadHaproxy, setWwwRedirection } from '$lib/haproxy';
import { getDomain } from '$lib/components/common';
import { PrismaErrorHandler } from '$lib/database';
@@ -52,6 +52,7 @@ export const post: RequestHandler = async (event) => {
if (isHttps) {
await letsEncrypt({ domain, id });
}
+ await setWwwRedirection(fqdn);
await reloadHaproxy(destinationDocker.engine);
return {
status: 200
diff --git a/src/routes/services/[id]/plausibleanalytics/start.json.ts b/src/routes/services/[id]/plausibleanalytics/start.json.ts
index 406e67adc..9314f9c01 100644
--- a/src/routes/services/[id]/plausibleanalytics/start.json.ts
+++ b/src/routes/services/[id]/plausibleanalytics/start.json.ts
@@ -4,7 +4,7 @@ import { promises as fs } from 'fs';
import yaml from 'js-yaml';
import type { RequestHandler } from '@sveltejs/kit';
import { letsEncrypt } from '$lib/letsencrypt';
-import { configureSimpleServiceProxyOn, reloadHaproxy } from '$lib/haproxy';
+import { configureSimpleServiceProxyOn, reloadHaproxy, setWwwRedirection } from '$lib/haproxy';
import { getDomain } from '$lib/components/common';
import { PrismaErrorHandler } from '$lib/database';
@@ -185,6 +185,7 @@ COPY ./init-db.sh /docker-entrypoint-initdb.d/init-db.sh`;
if (isHttps) {
await letsEncrypt({ domain, id });
}
+ await setWwwRedirection(fqdn);
await reloadHaproxy(destinationDocker.engine);
return {
status: 200
diff --git a/src/routes/services/[id]/vaultwarden/start.json.ts b/src/routes/services/[id]/vaultwarden/start.json.ts
index a84366092..f219acfb2 100644
--- a/src/routes/services/[id]/vaultwarden/start.json.ts
+++ b/src/routes/services/[id]/vaultwarden/start.json.ts
@@ -4,7 +4,7 @@ import { promises as fs } from 'fs';
import yaml from 'js-yaml';
import type { RequestHandler } from '@sveltejs/kit';
import { letsEncrypt } from '$lib/letsencrypt';
-import { configureSimpleServiceProxyOn, reloadHaproxy } from '$lib/haproxy';
+import { configureSimpleServiceProxyOn, reloadHaproxy, setWwwRedirection } from '$lib/haproxy';
import { getDomain } from '$lib/components/common';
import { getServiceImage, PrismaErrorHandler } from '$lib/database';
@@ -70,6 +70,7 @@ export const post: RequestHandler = async (event) => {
if (isHttps) {
await letsEncrypt({ domain, id });
}
+ await setWwwRedirection(fqdn);
await reloadHaproxy(destinationDocker.engine);
return {
status: 200
diff --git a/src/routes/services/[id]/vscodeserver/start.json.ts b/src/routes/services/[id]/vscodeserver/start.json.ts
index 4e762c7c7..8b58c575b 100644
--- a/src/routes/services/[id]/vscodeserver/start.json.ts
+++ b/src/routes/services/[id]/vscodeserver/start.json.ts
@@ -4,7 +4,7 @@ import { promises as fs } from 'fs';
import yaml from 'js-yaml';
import type { RequestHandler } from '@sveltejs/kit';
import { letsEncrypt } from '$lib/letsencrypt';
-import { configureSimpleServiceProxyOn, reloadHaproxy } from '$lib/haproxy';
+import { configureSimpleServiceProxyOn, reloadHaproxy, setWwwRedirection } from '$lib/haproxy';
import { getDomain } from '$lib/components/common';
import { PrismaErrorHandler } from '$lib/database';
@@ -80,6 +80,7 @@ export const post: RequestHandler = async (event) => {
if (isHttps) {
await letsEncrypt({ domain, id });
}
+ await setWwwRedirection(fqdn);
await reloadHaproxy(destinationDocker.engine);
return {
status: 200
diff --git a/src/routes/services/[id]/wordpress/start.json.ts b/src/routes/services/[id]/wordpress/start.json.ts
index ffb0c11e7..182cac019 100644
--- a/src/routes/services/[id]/wordpress/start.json.ts
+++ b/src/routes/services/[id]/wordpress/start.json.ts
@@ -4,7 +4,7 @@ import { promises as fs } from 'fs';
import yaml from 'js-yaml';
import type { RequestHandler } from '@sveltejs/kit';
import { letsEncrypt } from '$lib/letsencrypt';
-import { configureSimpleServiceProxyOn, reloadHaproxy } from '$lib/haproxy';
+import { configureSimpleServiceProxyOn, reloadHaproxy, setWwwRedirection } from '$lib/haproxy';
import { getDomain } from '$lib/components/common';
import { PrismaErrorHandler } from '$lib/database';
@@ -117,6 +117,7 @@ export const post: RequestHandler = async (event) => {
if (isHttps) {
await letsEncrypt({ domain, id });
}
+ await setWwwRedirection(fqdn);
await reloadHaproxy(destinationDocker.engine);
return {
status: 200
diff --git a/src/routes/settings/index.json.ts b/src/routes/settings/index.json.ts
index 3a2498179..48604156a 100644
--- a/src/routes/settings/index.json.ts
+++ b/src/routes/settings/index.json.ts
@@ -9,6 +9,8 @@ import {
forceSSLOffApplication,
forceSSLOnApplication,
reloadHaproxy,
+ removeWwwRedirection,
+ setWwwRedirection,
startCoolifyProxy
} from '$lib/haproxy';
import { letsEncrypt } from '$lib/letsencrypt';
@@ -45,9 +47,10 @@ export const del: RequestHandler = async (event) => {
const { fqdn } = await event.request.json();
try {
- await db.prisma.setting.update({ where: { fqdn }, data: { fqdn: null } });
const domain = getDomain(fqdn);
- await configureCoolifyProxyOff({ domain });
+ await db.prisma.setting.update({ where: { fqdn }, data: { fqdn: null } });
+ await configureCoolifyProxyOff(fqdn);
+ await removeWwwRedirection(domain);
return {
status: 201
};
@@ -77,9 +80,10 @@ export const post: RequestHandler = async (event) => {
await db.prisma.setting.update({ where: { id }, data: { isRegistrationEnabled } });
}
if (oldFqdn && oldFqdn !== fqdn) {
- const oldDomain = getDomain(oldFqdn);
if (oldFqdn) {
- await configureCoolifyProxyOff({ domain: oldDomain });
+ const oldDomain = getDomain(oldFqdn);
+ await configureCoolifyProxyOff(oldFqdn);
+ await removeWwwRedirection(oldDomain);
}
}
if (fqdn) {
@@ -88,7 +92,8 @@ export const post: RequestHandler = async (event) => {
const domain = getDomain(fqdn);
const isHttps = fqdn.startsWith('https://');
if (domain) {
- await configureCoolifyProxyOn({ domain });
+ await configureCoolifyProxyOn(fqdn);
+ await setWwwRedirection(fqdn);
if (isHttps && !dev) {
await letsEncrypt({ domain, isCoolify: true });
await forceSSLOnApplication({ domain });
diff --git a/src/routes/settings/index.svelte b/src/routes/settings/index.svelte
index 48407e8b3..91bba0e2b 100644
--- a/src/routes/settings/index.svelte
+++ b/src/routes/settings/index.svelte
@@ -106,7 +106,7 @@
Domain (FQDN)
-
diff --git a/src/routes/sources/[id]/_Gitlab.svelte b/src/routes/sources/[id]/_Gitlab.svelte
index 4530cc0e0..c95bbb1ba 100644
--- a/src/routes/sources/[id]/_Gitlab.svelte
+++ b/src/routes/sources/[id]/_Gitlab.svelte
@@ -71,8 +71,6 @@
window.open(`${source.htmlUrl}/groups/${payload.groupName}/-/settings/applications`);
break;
case 'instance':
- // TODO: This is not correct
- // window.location.assign(`${source.htmlUrl}/-/profile/applications`);
break;
default:
break;