From 1afe9384fd63d8decfd3285342e23940280b25b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Manuel=20Casani=20Guerra?= Date: Sat, 8 Oct 2022 18:54:58 +0000 Subject: [PATCH] Allow custom proxy host header to be set (#393) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :sparkles: feat: proxy header override * :bug: fix: missing translations key * :bug: fix: missing translations key, again 😅 * Update src/nginxconfig/i18n/en/templates/domain_sections/reverse_proxy.js Co-authored-by: Matt Cowley * :bulb: chore: bump copyright year * :art: refactor: update key to proxyHostHeader and i18n messages * :art: refactor: fix key in template Co-authored-by: Matt Cowley --- src/nginxconfig/generators/conf/proxy.conf.js | 3 +-- .../generators/conf/website.conf.js | 3 ++- .../domain_sections/reverse_proxy.js | 3 ++- .../domain_sections/reverse_proxy.js | 3 ++- .../domain_sections/reverse_proxy.js | 3 ++- .../domain_sections/reverse_proxy.js | 3 ++- .../domain_sections/reverse_proxy.js | 1 + .../domain_sections/reverse_proxy.js | 3 ++- .../domain_sections/reverse_proxy.js | 3 ++- .../domain_sections/reverse_proxy.js | 3 ++- .../domain_sections/reverse_proxy.js | 3 ++- .../domain_sections/reverse_proxy.js | 1 + .../domain_sections/reverse_proxy.vue | 26 +++++++++++++++++++ 13 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/nginxconfig/generators/conf/proxy.conf.js b/src/nginxconfig/generators/conf/proxy.conf.js index e6eb573..9c5407b 100644 --- a/src/nginxconfig/generators/conf/proxy.conf.js +++ b/src/nginxconfig/generators/conf/proxy.conf.js @@ -1,5 +1,5 @@ /* -Copyright 2021 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -33,7 +33,6 @@ export default global => { config['# Proxy headers'] = ''; config['proxy_set_header Upgrade'] = '$http_upgrade'; config['proxy_set_header Connection'] = '$connection_upgrade'; - config['proxy_set_header Host'] = '$host'; config['proxy_set_header X-Real-IP'] = '$remote_addr'; config['proxy_set_header Forwarded'] = '$proxy_add_forwarded'; if (global.reverseProxy.proxyCoexistenceXForwarded.computed == 'passOn') { diff --git a/src/nginxconfig/generators/conf/website.conf.js b/src/nginxconfig/generators/conf/website.conf.js index f08cb9a..0363f5d 100644 --- a/src/nginxconfig/generators/conf/website.conf.js +++ b/src/nginxconfig/generators/conf/website.conf.js @@ -1,5 +1,5 @@ /* -Copyright 2021 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -279,6 +279,7 @@ export default (domain, domains, global, ipPortPairs) => { if (domain.reverseProxy.reverseProxy.computed) { const locConf = []; locConf.push(['proxy_pass', domain.reverseProxy.proxyPass.computed]); + locConf.push(['proxy_set_header Host', domain.reverseProxy.proxyHostHeader.computed]); if (global.tools.modularizedStructure.computed) { // Modularized diff --git a/src/nginxconfig/i18n/de/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/de/templates/domain_sections/reverse_proxy.js index 4a095f9..52d9c66 100644 --- a/src/nginxconfig/i18n/de/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/de/templates/domain_sections/reverse_proxy.js @@ -1,5 +1,5 @@ /* -Copyright 2021 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `${common.reverseProxy} kann nicht aktiviert werden, während ${common.php} aktiviert ist.`, reverseProxyCannotBeEnabledWithPython: `${common.reverseProxy} kann nicht aktiviert werden, während ${common.python} aktiviert ist.`, enableReverseProxy: `${common.enable} ${common.reverseProxy}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/i18n/en/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/en/templates/domain_sections/reverse_proxy.js index d3e8748..8cd8ecf 100644 --- a/src/nginxconfig/i18n/en/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/en/templates/domain_sections/reverse_proxy.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `${common.reverseProxy} cannot be enabled whilst ${common.php} is enabled.`, reverseProxyCannotBeEnabledWithPython: `${common.reverseProxy} cannot be enabled whilst ${common.python} is enabled.`, enableReverseProxy: `${common.enable} ${common.reverseProxyLower}`, + proxyHostHeader: 'Proxy Host header', }; diff --git a/src/nginxconfig/i18n/es/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/es/templates/domain_sections/reverse_proxy.js index 0f493bd..b13ca31 100644 --- a/src/nginxconfig/i18n/es/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/es/templates/domain_sections/reverse_proxy.js @@ -1,5 +1,5 @@ /* -Copyright 2021 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `${common.reverseProxy} no se puede habilitar mientras ${common.php} está habilitado.`, reverseProxyCannotBeEnabledWithPython: `${common.reverseProxy} no se puede habilitar mientras ${common.python} está habilitado.`, enableReverseProxy: `${common.enable} ${common.reverseProxyLower}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/i18n/fr/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/fr/templates/domain_sections/reverse_proxy.js index 29f05d1..566c7fc 100644 --- a/src/nginxconfig/i18n/fr/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/fr/templates/domain_sections/reverse_proxy.js @@ -1,5 +1,5 @@ /* -Copyright 2021 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `Le ${common.reverseProxyLower} ne peut pas être activé en même temps que ${common.php}.`, reverseProxyCannotBeEnabledWithPython: `Le ${common.reverseProxyLower} ne peut pas être activé en même temps que ${common.python}.`, enableReverseProxy: `${common.enable} le ${common.reverseProxyLower}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/i18n/ja/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/ja/templates/domain_sections/reverse_proxy.js index d7add45..e4dcedf 100644 --- a/src/nginxconfig/i18n/ja/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/ja/templates/domain_sections/reverse_proxy.js @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `${common.php} が有効な場合は、 ${common.reverseProxy} を有効にすることはできません。`, reverseProxyCannotBeEnabledWithPython: `${common.python} が有効な場合は、 ${common.reverseProxy} を有効にすることはできません。`, enableReverseProxy: `${common.reverseProxyLower}を${common.enable}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/i18n/pl/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/pl/templates/domain_sections/reverse_proxy.js index 2a69abe..fb6e2ce 100644 --- a/src/nginxconfig/i18n/pl/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/pl/templates/domain_sections/reverse_proxy.js @@ -1,5 +1,5 @@ /* -Copyright 2021 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `${common.reverseProxy} nie może zostać włączony dopóki włączony jest ${common.php}.`, reverseProxyCannotBeEnabledWithPython: `${common.reverseProxy} nie może zostać włączony dopóki włączony jest ${common.python}.`, enableReverseProxy: `${common.enable} ${common.reverseProxyLower}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/i18n/pt-br/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/pt-br/templates/domain_sections/reverse_proxy.js index 84c1bfc..1234f5e 100644 --- a/src/nginxconfig/i18n/pt-br/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/pt-br/templates/domain_sections/reverse_proxy.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `O ${common.reverseProxy} não pode ser habilitado enquanto o ${common.php} estiver habilitado.`, reverseProxyCannotBeEnabledWithPython: `O ${common.reverseProxy} não pode ser habilitado enquanto o ${common.python} estiver habilitado.`, enableReverseProxy: `${common.enable} ${common.reverseProxyLower}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/i18n/ru/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/ru/templates/domain_sections/reverse_proxy.js index 6d109dd..728aa5a 100644 --- a/src/nginxconfig/i18n/ru/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/ru/templates/domain_sections/reverse_proxy.js @@ -1,5 +1,5 @@ /* -Copyright 2021 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `${common.reverseProxy} не может быть включен, пока включен ${common.php}.`, reverseProxyCannotBeEnabledWithPython: `${common.reverseProxy} не может быть включен, пока включен ${common.python}.`, enableReverseProxy: `${common.enable} ${common.reverseProxyLower}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/reverse_proxy.js index e43313f..f5c161f 100644 --- a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/reverse_proxy.js @@ -1,5 +1,5 @@ /* -Copyright 2020 DigitalOcean +Copyright 2022 DigitalOcean This code is licensed under the MIT License. You may obtain a copy of the License at @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `${common.reverseProxy}在启用${common.php}时无法启用。`, reverseProxyCannotBeEnabledWithPython: `${common.reverseProxy}在启用${common.python}时无法启用。`, enableReverseProxy: `${common.enable} ${common.reverseProxyLower}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/reverse_proxy.js b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/reverse_proxy.js index 41a8da2..14adbf0 100644 --- a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/reverse_proxy.js @@ -31,4 +31,5 @@ export default { reverseProxyCannotBeEnabledWithPhp: `${common.reverseProxy} 在啟用 ${common.php} 時無法啟用。`, reverseProxyCannotBeEnabledWithPython: `${common.reverseProxy} 在啟用 ${common.python} 時無法啟用。`, enableReverseProxy: `${common.enable}${common.reverseProxyLower}`, + proxyHostHeader: 'Proxy Host header', // TODO: translate }; diff --git a/src/nginxconfig/templates/domain_sections/reverse_proxy.vue b/src/nginxconfig/templates/domain_sections/reverse_proxy.vue index 2011ef6..05ccfd8 100644 --- a/src/nginxconfig/templates/domain_sections/reverse_proxy.vue +++ b/src/nginxconfig/templates/domain_sections/reverse_proxy.vue @@ -99,6 +99,24 @@ THE SOFTWARE. + +
+
+ +
+
+
+
+ +
+
+
+
@@ -120,6 +138,10 @@ THE SOFTWARE. default: 'http://127.0.0.1:3000', enabled: false, }, + proxyHostHeader: { + default: '$host', + enabled: false, + }, }; export default { @@ -157,11 +179,15 @@ THE SOFTWARE. this.$props.data.path.computed = this.$props.data.path.value; this.$props.data.proxyPass.enabled = true; this.$props.data.proxyPass.computed = this.$props.data.proxyPass.value; + this.$props.data.proxyHostHeader.enabled = true; + this.$props.data.proxyHostHeader.computed = this.$props.data.proxyHostHeader.value; } else { this.$props.data.path.enabled = false; this.$props.data.path.computed = ''; this.$props.data.proxyPass.enabled = false; this.$props.data.proxyPass.computed = ''; + this.$props.data.proxyHostHeader.enabled = false; + this.$props.data.proxyHostHeader.computed = ''; } }, deep: true,