fix: grpc
This commit is contained in:
parent
e98a8ba599
commit
9b5efab8f8
@ -3,8 +3,30 @@ import { errorHandler, getDomain, isDev, prisma, executeCommand } from '../../..
|
|||||||
import { getTemplates } from '../../../lib/services';
|
import { getTemplates } from '../../../lib/services';
|
||||||
import { OnlyId } from '../../../types';
|
import { OnlyId } from '../../../types';
|
||||||
|
|
||||||
function generateServices(serviceId, containerId, port, isHttp2 = false) {
|
function generateServices(serviceId, containerId, port, isHttp2 = false, isHttps = false) {
|
||||||
const payload = {
|
if (isHttp2) {
|
||||||
|
return {
|
||||||
|
[serviceId]: {
|
||||||
|
loadbalancer: {
|
||||||
|
servers: [
|
||||||
|
{
|
||||||
|
url: `${isHttps ? 'https' : 'http'}://${containerId}:${port}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[`${serviceId}-http2`]: {
|
||||||
|
loadbalancer: {
|
||||||
|
servers: [
|
||||||
|
{
|
||||||
|
url: `h2c://${containerId}:${port}`
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
[serviceId]: {
|
[serviceId]: {
|
||||||
loadbalancer: {
|
loadbalancer: {
|
||||||
servers: [
|
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(
|
function generateRouters(
|
||||||
serviceId,
|
serviceId,
|
||||||
@ -167,6 +177,7 @@ function generateRouters(
|
|||||||
service: `${serviceId}-http2`,
|
service: `${serviceId}-http2`,
|
||||||
rule: `${rule} && HeadersRegexp(\`Content-Type\`, \`application/grpc*\`)`
|
rule: `${rule} && HeadersRegexp(\`Content-Type\`, \`application/grpc*\`)`
|
||||||
};
|
};
|
||||||
|
|
||||||
let https2WWW = {
|
let https2WWW = {
|
||||||
...httpsWWW,
|
...httpsWWW,
|
||||||
service: `${serviceId}-http2`,
|
service: `${serviceId}-http2`,
|
||||||
@ -436,7 +447,7 @@ export async function proxyConfiguration(request: FastifyRequest<OnlyId>, remote
|
|||||||
};
|
};
|
||||||
traefik.http.services = {
|
traefik.http.services = {
|
||||||
...traefik.http.services,
|
...traefik.http.services,
|
||||||
...generateServices(serviceId, id, port, isHttp2)
|
...generateServices(serviceId, id, port, isHttp2, isHttps)
|
||||||
};
|
};
|
||||||
if (previews) {
|
if (previews) {
|
||||||
const { stdout } = await executeCommand({
|
const { stdout } = await executeCommand({
|
||||||
|
@ -717,7 +717,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 items-center pb-4">
|
<div class="grid grid-cols-2 items-center">
|
||||||
<Setting
|
<Setting
|
||||||
id="dualCerts"
|
id="dualCerts"
|
||||||
dataTooltip="Must be stopped to modify."
|
dataTooltip="Must be stopped to modify."
|
||||||
@ -729,16 +729,6 @@
|
|||||||
on:click={() => !isDisabled && changeSettings('dualCerts')}
|
on:click={() => !isDisabled && changeSettings('dualCerts')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 items-center pb-4">
|
|
||||||
<Setting
|
|
||||||
id="isHttp2"
|
|
||||||
isCenter={false}
|
|
||||||
bind:setting={isHttp2}
|
|
||||||
title="Enable h2c (HTTP/2 without TLS)"
|
|
||||||
description="Enable h2c protocol. <br><br>HTTP/2 is a major revision of the HTTP network protocol used by the World Wide Web that allows faster web page loading by reducing the number of requests needed to load a web page. <br><br>Useful for gRPC and other HTTP/2 based services."
|
|
||||||
on:click={() => changeSettings('isHttp2')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{#if isHttps && application.buildPack !== 'compose'}
|
{#if isHttps && application.buildPack !== 'compose'}
|
||||||
<div class="grid grid-cols-2 items-center pb-4">
|
<div class="grid grid-cols-2 items-center pb-4">
|
||||||
<Setting
|
<Setting
|
||||||
@ -751,6 +741,16 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="grid grid-cols-2 items-center pb-4">
|
||||||
|
<Setting
|
||||||
|
id="isHttp2"
|
||||||
|
isCenter={false}
|
||||||
|
bind:setting={isHttp2}
|
||||||
|
title="Enable HTTP/2 protocol?"
|
||||||
|
description="Enable HTTP/2 protocol. <br><br>HTTP/2 is a major revision of the HTTP network protocol used by the World Wide Web that allows faster web page loading by reducing the number of requests needed to load a web page.<br><br>Useful for gRPC and other HTTP/2 based services."
|
||||||
|
on:click={() => changeSettings('isHttp2')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if isSimpleDockerfile}
|
{#if isSimpleDockerfile}
|
||||||
|
@ -739,7 +739,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 items-center pb-4">
|
<div class="grid grid-cols-2 items-center">
|
||||||
<Setting
|
<Setting
|
||||||
id="dualCerts"
|
id="dualCerts"
|
||||||
dataTooltip={$t('forms.must_be_stopped_to_modify')}
|
dataTooltip={$t('forms.must_be_stopped_to_modify')}
|
||||||
@ -751,16 +751,7 @@
|
|||||||
on:click={() => !isDisabled && changeSettings('dualCerts')}
|
on:click={() => !isDisabled && changeSettings('dualCerts')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="grid grid-cols-2 items-center pb-4">
|
|
||||||
<Setting
|
|
||||||
id="isHttp2"
|
|
||||||
isCenter={false}
|
|
||||||
bind:setting={isHttp2}
|
|
||||||
title="Enable h2c (HTTP/2 without TLS)"
|
|
||||||
description="Enable h2c protocol. <br><br>HTTP/2 is a major revision of the HTTP network protocol used by the World Wide Web that allows faster web page loading by reducing the number of requests needed to load a web page.<br><br>Useful for gRPC and other HTTP/2 based services."
|
|
||||||
on:click={() => changeSettings('isHttp2')}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{#if isHttps && application.buildPack !== 'compose'}
|
{#if isHttps && application.buildPack !== 'compose'}
|
||||||
<div class="grid grid-cols-2 items-center pb-4">
|
<div class="grid grid-cols-2 items-center pb-4">
|
||||||
<Setting
|
<Setting
|
||||||
@ -773,6 +764,16 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="grid grid-cols-2 items-center pb-4">
|
||||||
|
<Setting
|
||||||
|
id="isHttp2"
|
||||||
|
isCenter={false}
|
||||||
|
bind:setting={isHttp2}
|
||||||
|
title="Enable HTTP/2 protocol?"
|
||||||
|
description="Enable HTTP/2 protocol. <br><br>HTTP/2 is a major revision of the HTTP network protocol used by the World Wide Web that allows faster web page loading by reducing the number of requests needed to load a web page.<br><br>Useful for gRPC and other HTTP/2 based services."
|
||||||
|
on:click={() => changeSettings('isHttp2')}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if isSimpleDockerfile}
|
{#if isSimpleDockerfile}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user