diff --git a/src/nginxconfig/generators/conf/nginx.conf.js b/src/nginxconfig/generators/conf/nginx.conf.js
index c23710a..c56b86e 100644
--- a/src/nginxconfig/generators/conf/nginx.conf.js
+++ b/src/nginxconfig/generators/conf/nginx.conf.js
@@ -27,7 +27,6 @@ THE SOFTWARE.
import sslProfiles from '../../util/ssl_profiles';
import websiteConf from './website.conf';
import shareQuery from '../../util/share_query';
-import phpPath from '../../util/php_path';
export default (domains, global) => {
const config = {};
@@ -51,14 +50,6 @@ export default (domains, global) => {
// HTTP (kv so we can use the same key multiple times)
config.http = [];
- if (global.php.phpBackupServer.computed)
- config.http.push(['upstream php', {
- server: [
- phpPath(global),
- `${phpPath(global, true)} backup`,
- ],
- }]);
-
config.http.push(['charset', 'utf-8']);
config.http.push(['sendfile', 'on']);
config.http.push(['tcp_nopush', 'on']);
diff --git a/src/nginxconfig/generators/conf/php_fastcgi.conf.js b/src/nginxconfig/generators/conf/php_fastcgi.conf.js
index f7f1d17..530a877 100644
--- a/src/nginxconfig/generators/conf/php_fastcgi.conf.js
+++ b/src/nginxconfig/generators/conf/php_fastcgi.conf.js
@@ -24,9 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-import phpPath from '../../util/php_path';
-
-export default (domains, global) => {
+export default (domains) => {
const legacyRouting = domains.some(d => d.routing.legacyPhpRouting.computed);
const config = {};
@@ -43,8 +41,6 @@ export default (domains, global) => {
config.include = 'fastcgi_params';
config['# fastcgi settings'] = '';
- config.fastcgi_pass = domains.some(d => d.php.php.computed) && global.php.phpBackupServer.computed !== ''
- ? 'php' : phpPath(global);
config.fastcgi_index = 'index.php';
config.fastcgi_buffers = '8 16k';
config.fastcgi_buffer_size = '32k';
diff --git a/src/nginxconfig/generators/conf/website.conf.js b/src/nginxconfig/generators/conf/website.conf.js
index dfd7d43..3146ec4 100644
--- a/src/nginxconfig/generators/conf/website.conf.js
+++ b/src/nginxconfig/generators/conf/website.conf.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -38,6 +38,8 @@ import drupalConf from './drupal.conf';
import magentoConf from './magento.conf';
import joomlaConf from './joomla.conf';
import letsEncryptConf from './letsencrypt.conf';
+import phpPath from '../../util/php_path';
+import phpUpstream from '../../util/php_upstream';
const sslConfig = (domain, global) => {
const config = [];
@@ -176,8 +178,8 @@ export default (domain, domains, global) => {
// Restrict Methods
if (Object.keys(domain.restrict).find(k => domain.restrict[k].computed && k !== 'responseCode')) {
const allowedKeys = Object.keys(domain.restrict)
- .filter(k => !domain.restrict[k].computed && k !== 'responseCode')
- .map(e => e.replace('Method', '').toUpperCase());
+ .filter(k => !domain.restrict[k].computed && k !== 'responseCode')
+ .map(e => e.replace('Method', '').toUpperCase());
serverConfig.push(['# restrict methods', '']);
serverConfig.push([`if ($request_method !~ ^(${allowedKeys.join('|')})$)`, {
@@ -284,15 +286,36 @@ export default (domain, domains, global) => {
// PHP
if (domain.php.php.computed) {
+ if (domain.php.phpBackupServer.computed) {
+ config.push([`upstream ${phpUpstream(domain)}`, {
+ server: [
+ phpPath(domain),
+ `${phpPath(domain, true)} backup`,
+ ],
+ }]);
+ }
+
serverConfig.push(['# handle .php', '']);
const loc = `location ~ ${domain.routing.legacyPhpRouting.computed ? '[^/]\\.php(/|$)' : '\\.php$'}`;
+
+ const fastcgiPass = {
+ fastcgi_pass: domain.php.phpBackupServer.computed !== ''
+ ? phpUpstream(domain) : phpPath(domain),
+ };
+
if (global.tools.modularizedStructure.computed || domain.php.wordPressRules.computed) {
// Modularized
- serverConfig.push([loc, { include: 'nginxconfig.io/php_fastcgi.conf' }]);
+ serverConfig.push([loc, {
+ ...fastcgiPass,
+ include: 'nginxconfig.io/php_fastcgi.conf',
+ }]);
} else {
// Unified
- serverConfig.push([loc, phpConf(domains, global)]);
+ serverConfig.push([loc, {
+ ...fastcgiPass,
+ ...phpConf(domains),
+ }]);
}
}
diff --git a/src/nginxconfig/generators/index.js b/src/nginxconfig/generators/index.js
index 1e79570..83e75f9 100644
--- a/src/nginxconfig/generators/index.js
+++ b/src/nginxconfig/generators/index.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -73,7 +73,7 @@ export default (domains, global) => {
// PHP
if (domains.some(d => d.php.php.computed))
- files['nginxconfig.io/php_fastcgi.conf'] = toConf(phpConf(domains, global));
+ files['nginxconfig.io/php_fastcgi.conf'] = toConf(phpConf(domains));
// Python
if (domains.some(d => d.python.python.computed))
@@ -102,7 +102,7 @@ export default (domains, global) => {
} else {
// PHP
if (domains.some(d => d.php.wordPressRules.computed))
- files['nginxconfig.io/php_fastcgi.conf'] = toConf(phpConf(domains, global));
+ files['nginxconfig.io/php_fastcgi.conf'] = toConf(phpConf(domains));
}
return files;
diff --git a/src/nginxconfig/i18n/en/templates/domain_sections/php.js b/src/nginxconfig/i18n/en/templates/domain_sections/php.js
index 8dc7a9d..a999200 100644
--- a/src/nginxconfig/i18n/en/templates/domain_sections/php.js
+++ b/src/nginxconfig/i18n/en/templates/domain_sections/php.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -39,4 +39,18 @@ export default {
enableMagentoRules: `${common.enable} ${common.magento}-specific rules`,
joomlaRules: `${common.joomla} rules`,
enableJoomlaRules: `${common.enable} ${common.joomla}-specific rules`,
+ phpServer: `${common.php} server`,
+ phpBackupServer: `${common.php} backup server`,
+ tcp: 'TCP',
+ hhvmSocket: 'HHVM socket',
+ php5Socket: '5.x socket',
+ php70Socket: '7.0 socket',
+ php71Socket: '7.1 socket',
+ php72Socket: '7.2 socket',
+ php73Socket: '7.3 socket',
+ php74Socket: '7.4 socket',
+ php80Socket: '8.0 socket',
+ phpSocket: 'PHP socket',
+ custom: 'Custom',
+ disabled: 'Disabled',
};
diff --git a/src/nginxconfig/i18n/en/templates/global_sections/index.js b/src/nginxconfig/i18n/en/templates/global_sections/index.js
index 8a8e3ac..35eba1d 100644
--- a/src/nginxconfig/i18n/en/templates/global_sections/index.js
+++ b/src/nginxconfig/i18n/en/templates/global_sections/index.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -28,11 +28,10 @@ import https from './https';
import logging from './logging';
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';
import docker from './docker';
-export default { https, logging, nginx, performance, php, python, reverseProxy, security, tools, docker };
+export default { https, logging, nginx, performance, python, reverseProxy, security, tools, docker };
diff --git a/src/nginxconfig/i18n/en/templates/global_sections/php.js b/src/nginxconfig/i18n/en/templates/global_sections/php.js
deleted file mode 100644
index 176a123..0000000
--- a/src/nginxconfig/i18n/en/templates/global_sections/php.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright 2021 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 {
- phpServer: `${common.php} server`,
- phpMustBeEnabledOnOneSite: `${common.php} must be enabled on at least one site to configure global ${common.php} settings.`,
- phpBackupServer: `${common.php} backup server`,
- tcp: 'TCP',
- hhvmSocket: 'HHVM socket',
- php5Socket: '5.x socket',
- php70Socket: '7.0 socket',
- php71Socket: '7.1 socket',
- php72Socket: '7.2 socket',
- php73Socket: '7.3 socket',
- php74Socket: '7.4 socket',
- php80Socket: '8.0 socket',
- phpSocket: 'PHP socket',
- custom: 'Custom',
- disabled: 'Disabled',
-};
diff --git a/src/nginxconfig/i18n/fr/templates/domain_sections/php.js b/src/nginxconfig/i18n/fr/templates/domain_sections/php.js
index 8611528..7bf0f51 100644
--- a/src/nginxconfig/i18n/fr/templates/domain_sections/php.js
+++ b/src/nginxconfig/i18n/fr/templates/domain_sections/php.js
@@ -39,4 +39,18 @@ export default {
enableMagentoRules: `${common.enable} les règles spécifiques à ${common.magento}`,
joomlaRules: `Règles ${common.joomla}`,
enableJoomlaRules: `${common.enable} les règles spécifiques à ${common.joomla}`,
+ phpServer: `Serveur ${common.php}`,
+ phpBackupServer: `Serveur de sauvegarde ${common.php}`,
+ tcp: 'TCP',
+ hhvmSocket: 'Socket HHVM',
+ php5Socket: 'Socket 5.x',
+ php70Socket: 'Socket 7.0',
+ php71Socket: 'Socket 7.1',
+ php72Socket: 'Socket 7.2',
+ php73Socket: 'Socket 7.3',
+ php74Socket: 'Socket 7.4',
+ php80Socket: 'Socket 8.0',
+ phpSocket: 'Socket PHP',
+ custom: 'Custom', // TODO: translate
+ disabled: 'Désactivé',
};
diff --git a/src/nginxconfig/i18n/fr/templates/global_sections/index.js b/src/nginxconfig/i18n/fr/templates/global_sections/index.js
index d111b52..35eba1d 100644
--- a/src/nginxconfig/i18n/fr/templates/global_sections/index.js
+++ b/src/nginxconfig/i18n/fr/templates/global_sections/index.js
@@ -28,11 +28,10 @@ import https from './https';
import logging from './logging';
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';
import docker from './docker';
-export default { https, logging, nginx, performance, php, python, reverseProxy, security, tools, docker };
+export default { https, logging, nginx, performance, python, reverseProxy, security, tools, docker };
diff --git a/src/nginxconfig/i18n/fr/templates/global_sections/php.js b/src/nginxconfig/i18n/fr/templates/global_sections/php.js
deleted file mode 100644
index c006f4f..0000000
--- a/src/nginxconfig/i18n/fr/templates/global_sections/php.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright 2021 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 {
- phpServer: `Serveur ${common.php}`,
- phpMustBeEnabledOnOneSite: `${common.php} doit être activé sur au moins un site pour configurer les paramètres globaux de ${common.php}.`,
- phpBackupServer: `Serveur de sauvegarde ${common.php}`,
- tcp: 'TCP',
- hhvmSocket: 'Socket HHVM',
- php5Socket: 'Socket 5.x',
- php70Socket: 'Socket 7.0',
- php71Socket: 'Socket 7.1',
- php72Socket: 'Socket 7.2',
- php73Socket: 'Socket 7.3',
- php74Socket: 'Socket 7.4',
- php80Socket: 'Socket 8.0',
- phpSocket: 'Socket PHP',
- custom: 'Custom', // TODO: translate
- disabled: 'Désactivé',
-};
diff --git a/src/nginxconfig/i18n/pt-br/templates/domain_sections/php.js b/src/nginxconfig/i18n/pt-br/templates/domain_sections/php.js
index 02e4d87..5474236 100644
--- a/src/nginxconfig/i18n/pt-br/templates/domain_sections/php.js
+++ b/src/nginxconfig/i18n/pt-br/templates/domain_sections/php.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -39,4 +39,18 @@ export default {
enableMagentoRules: `${common.enable} regras específicas do ${common.magento}`,
joomlaRules: `Regras do ${common.joomla}`,
enableJoomlaRules: `${common.enable} regras específicas do ${common.joomla}`,
+ phpServer: `Servidor ${common.php}`,
+ phpBackupServer: `Servidor de backup ${common.php}`,
+ tcp: 'TCP',
+ hhvmSocket: 'Socket HHVM',
+ php5Socket: 'Socket 5.x',
+ php70Socket: 'Socket 7.0',
+ php71Socket: 'Socket 7.1',
+ php72Socket: 'Socket 7.2',
+ php73Socket: 'Socket 7.3',
+ php74Socket: 'Socket 7.4',
+ php80Socket: 'Socket 8.0',
+ phpSocket: 'Socket PHP',
+ custom: 'Custom', // TODO: translate
+ disabled: 'Desabilitado',
};
diff --git a/src/nginxconfig/i18n/pt-br/templates/global_sections/index.js b/src/nginxconfig/i18n/pt-br/templates/global_sections/index.js
index 8a8e3ac..35eba1d 100644
--- a/src/nginxconfig/i18n/pt-br/templates/global_sections/index.js
+++ b/src/nginxconfig/i18n/pt-br/templates/global_sections/index.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -28,11 +28,10 @@ import https from './https';
import logging from './logging';
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';
import docker from './docker';
-export default { https, logging, nginx, performance, php, python, reverseProxy, security, tools, docker };
+export default { https, logging, nginx, performance, python, reverseProxy, security, tools, docker };
diff --git a/src/nginxconfig/i18n/pt-br/templates/global_sections/php.js b/src/nginxconfig/i18n/pt-br/templates/global_sections/php.js
deleted file mode 100644
index c8abcb4..0000000
--- a/src/nginxconfig/i18n/pt-br/templates/global_sections/php.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright 2021 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 {
- phpServer: `Servidor ${common.php}`,
- phpMustBeEnabledOnOneSite: `O ${common.php} deve estar habilitado em pelo menos um site para definir as configurações globais do ${common.php}.`,
- phpBackupServer: `Servidor de backup ${common.php}`,
- tcp: 'TCP',
- hhvmSocket: 'Socket HHVM',
- php5Socket: 'Socket 5.x',
- php70Socket: 'Socket 7.0',
- php71Socket: 'Socket 7.1',
- php72Socket: 'Socket 7.2',
- php73Socket: 'Socket 7.3',
- php74Socket: 'Socket 7.4',
- php80Socket: 'Socket 8.0',
- phpSocket: 'Socket PHP',
- custom: 'Custom', // TODO: translate
- disabled: 'Desabilitado',
-};
diff --git a/src/nginxconfig/i18n/ru/templates/domain_sections/php.js b/src/nginxconfig/i18n/ru/templates/domain_sections/php.js
index b623f92..332220a 100644
--- a/src/nginxconfig/i18n/ru/templates/domain_sections/php.js
+++ b/src/nginxconfig/i18n/ru/templates/domain_sections/php.js
@@ -39,4 +39,18 @@ export default {
enableMagentoRules: `${common.enable} ${common.magento}-специфичные правила`,
joomlaRules: `${common.joomla} правила`,
enableJoomlaRules: `${common.enable} ${common.joomla}-специфичные правила`,
+ phpServer: `${common.php} сервер`,
+ phpBackupServer: `${common.php} бекап сервер`,
+ tcp: 'TCP',
+ hhvmSocket: 'HHVM сокет',
+ php5Socket: '5.x сокет',
+ php70Socket: '7.0 сокет',
+ php71Socket: '7.1 сокет',
+ php72Socket: '7.2 сокет',
+ php73Socket: '7.3 сокет',
+ php74Socket: '7.4 сокет',
+ php80Socket: '8.0 сокет',
+ phpSocket: 'PHP сокет',
+ custom: 'Другой',
+ disabled: 'Выключено',
};
diff --git a/src/nginxconfig/i18n/ru/templates/global_sections/index.js b/src/nginxconfig/i18n/ru/templates/global_sections/index.js
index 8a8e3ac..7653a47 100644
--- a/src/nginxconfig/i18n/ru/templates/global_sections/index.js
+++ b/src/nginxconfig/i18n/ru/templates/global_sections/index.js
@@ -28,11 +28,10 @@ import https from './https';
import logging from './logging';
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';
import docker from './docker';
-export default { https, logging, nginx, performance, php, python, reverseProxy, security, tools, docker };
+export default { https, logging, nginx, performance, python, reverseProxy, security, tools, docker };
diff --git a/src/nginxconfig/i18n/ru/templates/global_sections/php.js b/src/nginxconfig/i18n/ru/templates/global_sections/php.js
deleted file mode 100644
index d003971..0000000
--- a/src/nginxconfig/i18n/ru/templates/global_sections/php.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-Copyright 2021 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 {
- phpServer: `${common.php} сервер`,
- phpMustBeEnabledOnOneSite: `${common.php} должен быть включен как минимум на одном сайте, чтобы сконфигурировать глобальные настройки ${common.php}.`,
- phpBackupServer: `${common.php} бекап сервер`,
- tcp: 'TCP',
- hhvmSocket: 'HHVM сокет',
- php5Socket: '5.x сокет',
- php70Socket: '7.0 сокет',
- php71Socket: '7.1 сокет',
- php72Socket: '7.2 сокет',
- php73Socket: '7.3 сокет',
- php74Socket: '7.4 сокет',
- php80Socket: '8.0 сокет',
- phpSocket: 'PHP сокет',
- custom: 'Другой',
- disabled: 'Выключено',
-};
diff --git a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/php.js b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/php.js
index 0ae0198..384e8f1 100644
--- a/src/nginxconfig/i18n/zh-cn/templates/domain_sections/php.js
+++ b/src/nginxconfig/i18n/zh-cn/templates/domain_sections/php.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -39,4 +39,18 @@ export default {
enableMagentoRules: `${common.enable} ${common.magento}专属规则`,
joomlaRules: `${common.joomla} 规则`,
enableJoomlaRules: `${common.enable} ${common.joomla}专属规则`,
+ phpServer: `${common.php} 服务`,
+ phpBackupServer: `${common.php}备份服务器`,
+ tcp: 'TCP',
+ hhvmSocket: 'HHVM socket',
+ php5Socket: '5.x socket',
+ php70Socket: '7.0 socket',
+ php71Socket: '7.1 socket',
+ php72Socket: '7.2 socket',
+ php73Socket: '7.3 socket',
+ php74Socket: '7.4 socket',
+ php80Socket: '8.0 socket',
+ phpSocket: 'PHP socket',
+ custom: '自定义',
+ disabled: '禁用',
};
diff --git a/src/nginxconfig/i18n/zh-cn/templates/global_sections/index.js b/src/nginxconfig/i18n/zh-cn/templates/global_sections/index.js
index 8a8e3ac..35eba1d 100644
--- a/src/nginxconfig/i18n/zh-cn/templates/global_sections/index.js
+++ b/src/nginxconfig/i18n/zh-cn/templates/global_sections/index.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -28,11 +28,10 @@ import https from './https';
import logging from './logging';
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';
import docker from './docker';
-export default { https, logging, nginx, performance, php, python, reverseProxy, security, tools, docker };
+export default { https, logging, nginx, performance, python, reverseProxy, security, tools, docker };
diff --git a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/php.js b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/php.js
index 55e81d3..dbb1106 100644
--- a/src/nginxconfig/i18n/zh-tw/templates/domain_sections/php.js
+++ b/src/nginxconfig/i18n/zh-tw/templates/domain_sections/php.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -39,4 +39,18 @@ export default {
enableMagentoRules: `${common.enable} ${common.magento}專屬規則`,
joomlaRules: `${common.joomla} 規則`,
enableJoomlaRules: `${common.enable} ${common.joomla}專屬規則`,
+ phpServer: `${common.php} 服務`,
+ phpBackupServer: `${common.php}備份服務器`,
+ tcp: 'TCP',
+ hhvmSocket: 'HHVM socket',
+ php5Socket: '5.x socket',
+ php70Socket: '7.0 socket',
+ php71Socket: '7.1 socket',
+ php72Socket: '7.2 socket',
+ php73Socket: '7.3 socket',
+ php74Socket: '7.4 socket',
+ php80Socket: '8.0 socket',
+ phpSocket: 'PHP socket',
+ custom: '自定义',
+ disabled: '禁用',
};
diff --git a/src/nginxconfig/i18n/zh-tw/templates/global_sections/index.js b/src/nginxconfig/i18n/zh-tw/templates/global_sections/index.js
index 8a8e3ac..7653a47 100644
--- a/src/nginxconfig/i18n/zh-tw/templates/global_sections/index.js
+++ b/src/nginxconfig/i18n/zh-tw/templates/global_sections/index.js
@@ -28,11 +28,10 @@ import https from './https';
import logging from './logging';
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';
import docker from './docker';
-export default { https, logging, nginx, performance, php, python, reverseProxy, security, tools, docker };
+export default { https, logging, nginx, performance, python, reverseProxy, security, tools, docker };
diff --git a/src/nginxconfig/templates/domain_sections/php.vue b/src/nginxconfig/templates/domain_sections/php.vue
index 458a3a0..5fed4e2 100644
--- a/src/nginxconfig/templates/domain_sections/php.vue
+++ b/src/nginxconfig/templates/domain_sections/php.vue
@@ -1,5 +1,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/nginxconfig/util/backwards_compatibility.js b/src/nginxconfig/util/angular_backwards_compatibility.js
similarity index 99%
rename from src/nginxconfig/util/backwards_compatibility.js
rename to src/nginxconfig/util/angular_backwards_compatibility.js
index 16e290e..117d6fd 100644
--- a/src/nginxconfig/util/backwards_compatibility.js
+++ b/src/nginxconfig/util/angular_backwards_compatibility.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
diff --git a/src/nginxconfig/i18n/zh-tw/templates/global_sections/php.js b/src/nginxconfig/util/deep_merge.js
similarity index 67%
rename from src/nginxconfig/i18n/zh-tw/templates/global_sections/php.js
rename to src/nginxconfig/util/deep_merge.js
index de71684..868ef2b 100644
--- a/src/nginxconfig/i18n/zh-tw/templates/global_sections/php.js
+++ b/src/nginxconfig/util/deep_merge.js
@@ -24,22 +24,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-import common from '../../common';
-
-export default {
- phpServer: `${common.php} 服務`,
- phpMustBeEnabledOnOneSite: `必須在至少一個網站上啟用${common.php}才能配寘全域${common.php}設定。`,
- phpBackupServer: `${common.php}備份服務器`,
- tcp: 'TCP',
- hhvmSocket: 'HHVM socket',
- php5Socket: '5.x socket',
- php70Socket: '7.0 socket',
- php71Socket: '7.1 socket',
- php72Socket: '7.2 socket',
- php73Socket: '7.3 socket',
- php74Socket: '7.4 socket',
- php80Socket: '8.0 socket',
- phpSocket: 'PHP socket',
- custom: '自定义',
- disabled: '禁用',
+export default (target, source) => {
+ const merge = (target, source) => {
+ Object.keys(source).forEach((key) => {
+ if (source[key] && typeof source[key] === 'object') {
+ merge(target[key] = target[key] || {}, source[key]);
+ return;
+ }
+ target[key] = source[key];
+ });
+ };
+ merge(target, source);
};
diff --git a/src/nginxconfig/util/import_data.js b/src/nginxconfig/util/import_data.js
index 7f44ecb..fbd95ed 100644
--- a/src/nginxconfig/util/import_data.js
+++ b/src/nginxconfig/util/import_data.js
@@ -1,5 +1,5 @@
/*
-Copyright 2020 DigitalOcean
+Copyright 2021 DigitalOcean
This code is licensed under the MIT License.
You may obtain a copy of the License at
@@ -28,7 +28,8 @@ import qs from 'qs';
import clone from 'clone';
import Domain from '../templates/domain';
import isObject from './is_object';
-import backwardsCompatibility from './backwards_compatibility';
+import angularBackwardsCompatibility from './angular_backwards_compatibility';
+import vueBackwardsCompatibility from './vue_backwards_compatibility';
const applyCategories = (categories, target) => {
// Work through each potential category
@@ -86,7 +87,10 @@ export default (query, domains, global, nextTick) => new Promise(resolve => {
});
// Handle converting nginxconfig.io-angular params to the current version
- backwardsCompatibility(data);
+ angularBackwardsCompatibility(data);
+
+ // Handle converting vue params to the current version
+ vueBackwardsCompatibility(data);
// Handle domains
if ('domains' in data && isObject(data.domains)) {
diff --git a/src/nginxconfig/util/php_path.js b/src/nginxconfig/util/php_path.js
index 219ff7e..8ade1d4 100644
--- a/src/nginxconfig/util/php_path.js
+++ b/src/nginxconfig/util/php_path.js
@@ -24,8 +24,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-export default (global, backup = false) => {
+export default (domain, backup = false) => {
const key = `php${backup ? 'Backup' : ''}Server`;
- if (global.php[key].computed === 'custom') return global.php[`${key}Custom`].computed;
- return (global.php[key].computed[0] === '/' ? 'unix:' : '') + global.php[key].computed;
+ if (domain.php[key].computed === 'custom') return domain.php[`${key}Custom`].computed;
+ return (domain.php[key].computed[0] === '/' ? 'unix:' : '') + domain.php[key].computed;
};
diff --git a/src/nginxconfig/i18n/zh-cn/templates/global_sections/php.js b/src/nginxconfig/util/php_upstream.js
similarity index 66%
rename from src/nginxconfig/i18n/zh-cn/templates/global_sections/php.js
rename to src/nginxconfig/util/php_upstream.js
index 2360aef..16bc9b7 100644
--- a/src/nginxconfig/i18n/zh-cn/templates/global_sections/php.js
+++ b/src/nginxconfig/util/php_upstream.js
@@ -24,22 +24,4 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
-import common from '../../common';
-
-export default {
- phpServer: `${common.php} 服务`,
- phpMustBeEnabledOnOneSite: `必须在至少一个站点上启用${common.php}才能配置全局${common.php}设置。`,
- phpBackupServer: `${common.php}备份服务器`,
- tcp: 'TCP',
- hhvmSocket: 'HHVM socket',
- php5Socket: '5.x socket',
- php70Socket: '7.0 socket',
- php71Socket: '7.1 socket',
- php72Socket: '7.2 socket',
- php73Socket: '7.3 socket',
- php74Socket: '7.4 socket',
- php80Socket: '8.0 socket',
- phpSocket: 'PHP socket',
- custom: '自定义',
- disabled: '禁用',
-};
+export default (domain) => `php_${domain.server.domain.computed.replace(/\./g, '_')}`;
diff --git a/src/nginxconfig/util/vue_backwards_compatibility.js b/src/nginxconfig/util/vue_backwards_compatibility.js
new file mode 100644
index 0000000..a3ab923
--- /dev/null
+++ b/src/nginxconfig/util/vue_backwards_compatibility.js
@@ -0,0 +1,71 @@
+/*
+Copyright 2021 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 isObject from './is_object';
+import deepMerge from './deep_merge';
+
+// Handle converting the old query format to our new query params
+export default data => {
+ // Handle converting old domain settings to new ones
+ if ('global' in data && isObject(data.global)) {
+ // Handle specifics global data
+ const mappedData = {
+ php: {},
+ };
+
+ // Keys to map
+ const keysToMap = {
+ php: [
+ 'phpServer',
+ 'phpServerCustom',
+ 'phpBackupServer',
+ 'phpBackupServerCustom',
+ ],
+ };
+
+ for (const key in data.global) {
+ if (!Object.prototype.hasOwnProperty.call(data.global, key)) continue;
+
+ // Skip if key doesn't need to be mapped
+ if (!Object.prototype.hasOwnProperty.call(keysToMap, key)) continue;
+
+ for (const key2 in data.global[key]) {
+ if (!Object.prototype.hasOwnProperty.call(data.global[key], key2)) continue;
+
+ if (keysToMap[key].includes(key2)) {
+ mappedData[key][key2] = data.global[key][key2];
+ }
+ }
+ }
+
+ for (const key in data.domains) {
+ if (!Object.prototype.hasOwnProperty.call(data.domains, key)) continue;
+
+ // Deep merge the mapped data
+ deepMerge(data.domains[key], mappedData);
+ }
+ }
+};