fix: SSL app off
This commit is contained in:
parent
24a6bcbd1e
commit
0ed87a5dfc
@ -67,42 +67,40 @@ export async function removeProxyConfiguration({ domain }) {
|
|||||||
await removeWwwRedirection(domain);
|
await removeWwwRedirection(domain);
|
||||||
}
|
}
|
||||||
export async function forceSSLOffApplication({ domain }) {
|
export async function forceSSLOffApplication({ domain }) {
|
||||||
if (!dev) {
|
const haproxy = await haproxyInstance();
|
||||||
const haproxy = await haproxyInstance();
|
await checkHAProxy(haproxy);
|
||||||
await checkHAProxy(haproxy);
|
let transactionId;
|
||||||
let transactionId;
|
try {
|
||||||
try {
|
const rules: any = await haproxy
|
||||||
const rules: any = await haproxy
|
.get(`v2/services/haproxy/configuration/http_request_rules`, {
|
||||||
.get(`v2/services/haproxy/configuration/http_request_rules`, {
|
searchParams: {
|
||||||
searchParams: {
|
parent_name: 'http',
|
||||||
parent_name: 'http',
|
parent_type: 'frontend'
|
||||||
parent_type: 'frontend'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.json();
|
|
||||||
if (rules.data.length > 0) {
|
|
||||||
const rule = rules.data.find((rule) => rule.cond_test.includes(`-i ${domain}`));
|
|
||||||
if (rule) {
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
.json();
|
||||||
|
if (rules.data.length > 0) {
|
||||||
|
const rule = rules.data.find((rule) =>
|
||||||
|
rule.cond_test.includes(`{ hdr(host) -i ${domain} } !{ ssl_fc }`)
|
||||||
|
);
|
||||||
|
if (rule) {
|
||||||
|
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();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
} finally {
|
|
||||||
if (transactionId) await completeTransaction(transactionId);
|
|
||||||
}
|
}
|
||||||
} else {
|
} catch (error) {
|
||||||
console.log(`[DEBUG] Removing ssl for ${domain}`);
|
console.log(error);
|
||||||
|
} finally {
|
||||||
|
if (transactionId) await completeTransaction(transactionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export async function forceSSLOnApplication({ domain }) {
|
export async function forceSSLOnApplication({ domain }) {
|
||||||
@ -273,6 +271,7 @@ export async function configureProxyForApplication({ domain, imageId, applicatio
|
|||||||
|
|
||||||
export async function configureCoolifyProxyOff(fqdn) {
|
export async function configureCoolifyProxyOff(fqdn) {
|
||||||
const domain = getDomain(fqdn);
|
const domain = getDomain(fqdn);
|
||||||
|
const isHttps = fqdn.startsWith('https://');
|
||||||
const haproxy = await haproxyInstance();
|
const haproxy = await haproxyInstance();
|
||||||
await checkHAProxy(haproxy);
|
await checkHAProxy(haproxy);
|
||||||
|
|
||||||
@ -287,10 +286,8 @@ export async function configureCoolifyProxyOff(fqdn) {
|
|||||||
})
|
})
|
||||||
.json();
|
.json();
|
||||||
await completeTransaction(transactionId);
|
await completeTransaction(transactionId);
|
||||||
if (!dev) {
|
if (isHttps) await forceSSLOffApplication({ domain });
|
||||||
await forceSSLOffApplication({ domain });
|
await removeWwwRedirection(fqdn);
|
||||||
}
|
|
||||||
await setWwwRedirection(fqdn);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error?.response?.body || error;
|
throw error?.response?.body || error;
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
import { dev } from '$app/env';
|
|
||||||
import { getDomain, getUserDetails } from '$lib/common';
|
import { getDomain, getUserDetails } from '$lib/common';
|
||||||
import * as db from '$lib/database';
|
import * as db from '$lib/database';
|
||||||
import { listSettings, ErrorHandler } from '$lib/database';
|
import { listSettings, ErrorHandler } from '$lib/database';
|
||||||
import {
|
import {
|
||||||
checkContainer,
|
|
||||||
configureCoolifyProxyOff,
|
configureCoolifyProxyOff,
|
||||||
configureCoolifyProxyOn,
|
configureCoolifyProxyOn,
|
||||||
forceSSLOffApplication,
|
|
||||||
forceSSLOnApplication,
|
forceSSLOnApplication,
|
||||||
reloadHaproxy,
|
reloadHaproxy,
|
||||||
removeWwwRedirection,
|
removeWwwRedirection,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user