Keep original Host on HTTPS upstreams, add use_upstream_host option

This commit is contained in:
Eduardo Silva
2026-11-25 17:42:14 -03:00
parent 543089b992
commit 832f91b5d4
6 changed files with 58 additions and 19 deletions
+1
View File
@@ -64,6 +64,7 @@ def build_applications_data(worker=None):
'hosts': list(app.hosts.values_list('hostname', flat=True)),
'upstream': app.upstream,
'allow_invalid_cert': app.allow_invalid_cert,
'use_upstream_host': app.use_upstream_host,
}
entries.append(entry)
return {'entries': entries}
+3 -1
View File
@@ -21,11 +21,12 @@ DOMAIN_PATTERN = re.compile(r'^(?=.{1,253}$)([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\
class ApplicationForm(forms.ModelForm):
class Meta:
model = Application
fields = ['display_name', 'upstream', 'allow_invalid_cert', 'serve_on_primary', 'all_workers', 'workers']
fields = ['display_name', 'upstream', 'allow_invalid_cert', 'use_upstream_host', 'serve_on_primary', 'all_workers', 'workers']
labels = {
'display_name': _('Name'),
'upstream': _('Upstream'),
'allow_invalid_cert': _('Allow invalid/self-signed certificate'),
'use_upstream_host': _('Send the upstream address as Host'),
'serve_on_primary': _('Serve on the primary server'),
'all_workers': _('Serve on all cluster workers'),
'workers': _('Cluster workers'),
@@ -70,6 +71,7 @@ class ApplicationForm(forms.ModelForm):
Div(
Div('upstream', css_class='col-md-12'),
Div('allow_invalid_cert', css_class='col-md-12'),
Div('use_upstream_host', css_class='col-md-12'),
css_class='row'
),
*cluster_rows,
@@ -0,0 +1,18 @@
# Generated by Django 5.2.19 on 2026-11-25 18:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app_gateway', '0014_dnschallengecredential_delegation_domain'),
]
operations = [
migrations.AddField(
model_name='application',
name='use_upstream_host',
field=models.BooleanField(default=False, help_text='Enable when the upstream selects the site by name, such as shared hosting, cloud services or CDNs. By default, the original Host of the request is sent.'),
),
]
+1
View File
@@ -67,6 +67,7 @@ class Application(models.Model):
display_name = models.CharField(max_length=128, blank=True)
upstream = models.CharField(max_length=255, help_text=_("Upstream address, e.g.: http://10.188.18.27:3000"))
allow_invalid_cert = models.BooleanField(default=False, help_text=_("Allow invalid or self-signed TLS certificates from the upstream"))
use_upstream_host = models.BooleanField(default=False, help_text=_("Enable when the upstream selects the site by name, such as shared hosting, cloud services or CDNs. By default, the original Host of the request is sent."))
serve_on_primary = models.BooleanField(default=True)
all_workers = models.BooleanField(default=False)
workers = models.ManyToManyField('cluster.Worker', blank=True, related_name='applications')