diff --git a/src/nginxconfig/generators/conf/proxy.conf.js b/src/nginxconfig/generators/conf/proxy.conf.js index 1164877..3f136f3 100644 --- a/src/nginxconfig/generators/conf/proxy.conf.js +++ b/src/nginxconfig/generators/conf/proxy.conf.js @@ -24,12 +24,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -export default () => { +export default global => { const config = {}; config.proxy_http_version = '1.1'; config.proxy_cache_bypass = '$http_upgrade'; + config['# Proxy headers'] = ''; config['proxy_set_header Upgrade'] = '$http_upgrade'; config['proxy_set_header Connection'] = '"upgrade"'; config['proxy_set_header Host'] = '$host'; @@ -39,6 +40,11 @@ export default () => { config['proxy_set_header X-Forwarded-Host'] = '$host'; config['proxy_set_header X-Forwarded-Port'] = '$server_port'; + config['# Proxy timeouts'] = ''; + config['proxy_connect_timeout'] = global.reverseProxy.proxyConnectTimeout.computed; + config['proxy_send_timeout'] = global.reverseProxy.proxySendTimeout.computed; + config['proxy_read_timeout'] = global.reverseProxy.proxyReadTimeout.computed; + // Done! return config; }; diff --git a/src/nginxconfig/generators/conf/website.conf.js b/src/nginxconfig/generators/conf/website.conf.js index 06ddc53..393a13c 100644 --- a/src/nginxconfig/generators/conf/website.conf.js +++ b/src/nginxconfig/generators/conf/website.conf.js @@ -200,7 +200,7 @@ export default (domain, domains, global) => { locConf.push(['include', 'nginxconfig.io/proxy.conf']); } else { // Unified - locConf.push(...Object.entries(proxyConf())); + locConf.push(...Object.entries(proxyConf(global))); } serverConfig.push(['# reverse proxy', '']); diff --git a/src/nginxconfig/generators/index.js b/src/nginxconfig/generators/index.js index 89f9706..89d41d5 100644 --- a/src/nginxconfig/generators/index.js +++ b/src/nginxconfig/generators/index.js @@ -70,7 +70,7 @@ export default (domains, global) => { // Reverse proxy if (domains.some(d => d.reverseProxy.reverseProxy.computed)) - files['nginxconfig.io/proxy.conf'] = toConf(proxyConf()); + files['nginxconfig.io/proxy.conf'] = toConf(proxyConf(global)); // WordPress if (domains.some(d => d.php.wordPressRules.computed)) diff --git a/src/nginxconfig/i18n/en/common.js b/src/nginxconfig/i18n/en/common.js index 1bfe8c8..42c1450 100644 --- a/src/nginxconfig/i18n/en/common.js +++ b/src/nginxconfig/i18n/en/common.js @@ -40,4 +40,6 @@ export default { magento: 'Magento', django: 'Django', logging: 'Logging', + reverseProxy: 'Reverse proxy', + reverseProxyLower: 'reverse proxy', }; 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 2870b80..5a7ed97 100644 --- a/src/nginxconfig/i18n/en/templates/domain_sections/reverse_proxy.js +++ b/src/nginxconfig/i18n/en/templates/domain_sections/reverse_proxy.js @@ -27,10 +27,9 @@ THE SOFTWARE. import common from '../../common'; export default { - reverseProxy: 'Reverse proxy', - reverseProxyIsDisabled: 'Reverse proxy is disabled.', - reverseProxyCannotBeEnabledWithPhp: `Reverse proxy cannot be enabled whilst ${common.php} is enabled.`, - reverseProxyCannotBeEnabledWithPython: `Reverse proxy cannot be enabled whilst ${common.python} is enabled.`, - enableReverseProxy: `${common.enable} reverse proxy`, + reverseProxyIsDisabled: `${common.reverseProxy} is disabled.`, + 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}`, path: 'Path', }; diff --git a/src/nginxconfig/i18n/en/templates/global_sections/index.js b/src/nginxconfig/i18n/en/templates/global_sections/index.js index 0805d80..32c3a17 100644 --- a/src/nginxconfig/i18n/en/templates/global_sections/index.js +++ b/src/nginxconfig/i18n/en/templates/global_sections/index.js @@ -30,7 +30,8 @@ import nginx from './nginx'; import performance from './performance'; import php from './php'; import python from './python'; +import reverseProxy from './reverse_proxy'; import security from './security'; import tools from './tools'; -export default { https, logging, nginx, performance, php, python, security, tools }; +export default { https, logging, nginx, performance, php, python, reverseProxy, security, tools }; diff --git a/src/nginxconfig/i18n/en/templates/global_sections/reverse_proxy.js b/src/nginxconfig/i18n/en/templates/global_sections/reverse_proxy.js new file mode 100644 index 0000000..612a9aa --- /dev/null +++ b/src/nginxconfig/i18n/en/templates/global_sections/reverse_proxy.js @@ -0,0 +1,32 @@ +/* +Copyright 2020 DigitalOcean + +This code is licensed under the MIT License. +You may obtain a copy of the License at +https://github.com/digitalocean/nginxconfig.io/blob/master/LICENSE or https://mit-license.org/ + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions : + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +import common from '../../common'; + +export default { + reverseProxyMustBeEnabledOnOneSite: `${common.reverseProxy} must be enabled on at least one site to configure global ${common.reverseProxyLower} settings.`, + seconds: 'seconds', +}; diff --git a/src/nginxconfig/templates/domain_sections/reverse_proxy.vue b/src/nginxconfig/templates/domain_sections/reverse_proxy.vue index 5d19763..aa842d1 100644 --- a/src/nginxconfig/templates/domain_sections/reverse_proxy.vue +++ b/src/nginxconfig/templates/domain_sections/reverse_proxy.vue @@ -28,7 +28,7 @@ THE SOFTWARE.
- +
@@ -49,7 +49,7 @@ THE SOFTWARE.
- +
@@ -123,22 +123,22 @@ THE SOFTWARE. }; export default { - name: 'DomainReverseProxy', // Component name - display: i18n.templates.domainSections.reverseProxy.reverseProxy, // Display name for tab - key: 'reverseProxy', // Key for data in parent - delegated: delegatedFromDefaults(defaults), // Data the parent will present here + name: 'DomainReverseProxy', // Component name + display: i18n.common.reverseProxy, // Display name for tab + key: 'reverseProxy', // Key for data in parent + delegated: delegatedFromDefaults(defaults), // Data the parent will present here components: { PrettyCheck, }, props: { - data: Object, // Data delegated back to us from parent + data: Object, // Data delegated back to us from parent }, data () { return { i18n, }; }, - computed: computedFromDefaults(defaults, 'reverseProxy'), // Getters & setters for the delegated data + computed: computedFromDefaults(defaults, 'reverseProxy'), // Getters & setters for the delegated data watch: { // If the PHP or Python is enabled, the Reverse proxy will be forced off '$parent.$props.data': { diff --git a/src/nginxconfig/templates/global_sections/index.js b/src/nginxconfig/templates/global_sections/index.js index 28b123f..1b850bc 100644 --- a/src/nginxconfig/templates/global_sections/index.js +++ b/src/nginxconfig/templates/global_sections/index.js @@ -28,6 +28,7 @@ export { default as HTTPS } from './https'; export { default as Security } from './security'; export { default as PHP } from './php'; export { default as Python } from './python'; +export { default as ReverseProxy } from './reverse_proxy'; export { default as Performance } from './performance'; export { default as Logging } from './logging'; export { default as NGINX } from './nginx'; diff --git a/src/nginxconfig/templates/global_sections/reverse_proxy.vue b/src/nginxconfig/templates/global_sections/reverse_proxy.vue new file mode 100644 index 0000000..520ffba --- /dev/null +++ b/src/nginxconfig/templates/global_sections/reverse_proxy.vue @@ -0,0 +1,213 @@ + + + + +