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); 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;
@ -81,7 +80,9 @@ export async function forceSSLOffApplication({ domain }) {
}) })
.json(); .json();
if (rules.data.length > 0) { 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) { if (rule) {
transactionId = await getNextTransactionId(); transactionId = await getNextTransactionId();
@ -101,9 +102,6 @@ export async function forceSSLOffApplication({ domain }) {
} finally { } finally {
if (transactionId) await completeTransaction(transactionId); if (transactionId) await completeTransaction(transactionId);
} }
} else {
console.log(`[DEBUG] Removing ssl for ${domain}`);
}
} }
export async function forceSSLOnApplication({ domain }) { export async function forceSSLOnApplication({ domain }) {
if (!dev) { if (!dev) {
@ -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;
} }

View File

@ -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,