fix: SSL app off

This commit is contained in:
Andras Bacsai 2022-02-17 23:47:37 +01:00
parent 24a6bcbd1e
commit 0ed87a5dfc
2 changed files with 34 additions and 40 deletions

View File

@ -67,7 +67,6 @@ export async function removeProxyConfiguration({ domain }) {
await removeWwwRedirection(domain);
}
export async function forceSSLOffApplication({ domain }) {
if (!dev) {
const haproxy = await haproxyInstance();
await checkHAProxy(haproxy);
let transactionId;
@ -81,7 +80,9 @@ export async function forceSSLOffApplication({ domain }) {
})
.json();
if (rules.data.length > 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) {
transactionId = await getNextTransactionId();
@ -101,9 +102,6 @@ export async function forceSSLOffApplication({ domain }) {
} finally {
if (transactionId) await completeTransaction(transactionId);
}
} else {
console.log(`[DEBUG] Removing ssl for ${domain}`);
}
}
export async function forceSSLOnApplication({ domain }) {
if (!dev) {
@ -273,6 +271,7 @@ export async function configureProxyForApplication({ domain, imageId, applicatio
export async function configureCoolifyProxyOff(fqdn) {
const domain = getDomain(fqdn);
const isHttps = fqdn.startsWith('https://');
const haproxy = await haproxyInstance();
await checkHAProxy(haproxy);
@ -287,10 +286,8 @@ export async function configureCoolifyProxyOff(fqdn) {
})
.json();
await completeTransaction(transactionId);
if (!dev) {
await forceSSLOffApplication({ domain });
}
await setWwwRedirection(fqdn);
if (isHttps) await forceSSLOffApplication({ domain });
await removeWwwRedirection(fqdn);
} catch (error) {
throw error?.response?.body || error;
}

View File

@ -1,12 +1,9 @@
import { dev } from '$app/env';
import { getDomain, getUserDetails } from '$lib/common';
import * as db from '$lib/database';
import { listSettings, ErrorHandler } from '$lib/database';
import {
checkContainer,
configureCoolifyProxyOff,
configureCoolifyProxyOn,
forceSSLOffApplication,
forceSSLOnApplication,
reloadHaproxy,
removeWwwRedirection,