fix: Proxy for http

This commit is contained in:
Andras Bacsai
2022-05-19 10:20:43 +02:00
parent eb62888c39
commit c0d711170b
5 changed files with 34 additions and 18 deletions

View File

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

View File

@@ -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'
};
}
}
}
}
}