fix: grpc

This commit is contained in:
Andras Bacsai
2023-01-17 11:51:53 +01:00
parent e98a8ba599
commit 9b5efab8f8
3 changed files with 49 additions and 37 deletions

View File

@@ -3,8 +3,30 @@ import { errorHandler, getDomain, isDev, prisma, executeCommand } from '../../..
import { getTemplates } from '../../../lib/services';
import { OnlyId } from '../../../types';
function generateServices(serviceId, containerId, port, isHttp2 = false) {
const payload = {
function generateServices(serviceId, containerId, port, isHttp2 = false, isHttps = false) {
if (isHttp2) {
return {
[serviceId]: {
loadbalancer: {
servers: [
{
url: `${isHttps ? 'https' : 'http'}://${containerId}:${port}`
}
]
}
},
[`${serviceId}-http2`]: {
loadbalancer: {
servers: [
{
url: `h2c://${containerId}:${port}`
}
]
}
}
};
}
return {
[serviceId]: {
loadbalancer: {
servers: [
@@ -15,18 +37,6 @@ function generateServices(serviceId, containerId, port, isHttp2 = false) {
}
}
};
if (isHttp2) {
payload[`${serviceId}-http2`] = {
loadbalancer: {
servers: [
{
url: `h2c://${containerId}:${port}`
}
]
}
};
}
return payload;
}
function generateRouters(
serviceId,
@@ -167,6 +177,7 @@ function generateRouters(
service: `${serviceId}-http2`,
rule: `${rule} && HeadersRegexp(\`Content-Type\`, \`application/grpc*\`)`
};
let https2WWW = {
...httpsWWW,
service: `${serviceId}-http2`,
@@ -436,7 +447,7 @@ export async function proxyConfiguration(request: FastifyRequest<OnlyId>, remote
};
traefik.http.services = {
...traefik.http.services,
...generateServices(serviceId, id, port, isHttp2)
...generateServices(serviceId, id, port, isHttp2, isHttps)
};
if (previews) {
const { stdout } = await executeCommand({