84 lines
3.0 KiB
JavaScript
84 lines
3.0 KiB
JavaScript
/*
|
|
Copyright 2020 DigitalOcean
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
import toConf from './to_conf';
|
|
import nginxConf from './conf/nginx.conf';
|
|
import websiteConf from './conf/website.conf';
|
|
import letsEncryptConf from './conf/letsencrypt.conf';
|
|
import securityConf from './conf/security.conf';
|
|
import generalConf from './conf/general.conf';
|
|
import phpConf from './conf/php_fastcgi.conf';
|
|
import pythonConf from './conf/python_uwsgi.conf';
|
|
import proxyConf from './conf/proxy.conf';
|
|
import wordPressConf from './conf/wordpress.conf';
|
|
import drupalConf from './conf/drupal.conf';
|
|
import magentoConf from './conf/magento.conf';
|
|
|
|
export default (domains, global) => {
|
|
const files = [];
|
|
|
|
// Base nginx config
|
|
files.push(['nginx.conf', toConf(nginxConf(domains, global))]);
|
|
|
|
// Modularised configs
|
|
if (global.tools.modularizedStructure.computed) {
|
|
// Domain config
|
|
for (const domain of domains) {
|
|
files.push([
|
|
`sites-${global.tools.symlinkVhost.computed ? 'available' : 'enabled'}/${domain.server.domain.computed}.conf`,
|
|
toConf(websiteConf(domain, domains, global)),
|
|
]);
|
|
}
|
|
|
|
// Let's encrypt
|
|
if (domains.some(d => d.https.certType.computed === 'letsEncrypt'))
|
|
files.push(['nginxconfig.io/letsencrypt.conf', toConf(letsEncryptConf(global))]);
|
|
|
|
// Security
|
|
files.push(['nginxconfig.io/security.conf', toConf(securityConf(domains, global))]);
|
|
|
|
// General
|
|
files.push(['nginxconfig.io/general.conf', toConf(generalConf(domains, global))]);
|
|
|
|
// PHP
|
|
if (domains.some(d => d.php.php.computed))
|
|
files.push(['nginxconfig.io/php_fastcgi.conf', toConf(phpConf(domains, global))]);
|
|
|
|
// Python
|
|
if (domains.some(d => d.python.python.computed))
|
|
files.push(['nginxconfig.io/python_uwsgi.conf', toConf(pythonConf(global))]);
|
|
|
|
// Reverse proxy
|
|
if (domains.some(d => d.reverseProxy.reverseProxy.computed))
|
|
files.push(['nginxconfig.io/proxy.conf', toConf(proxyConf())]);
|
|
|
|
// WordPress
|
|
if (domains.some(d => d.php.wordPressRules.computed))
|
|
files.push(['nginxconfig.io/wordpress.conf', toConf(wordPressConf(global))]);
|
|
|
|
// Drupal
|
|
if (domains.some(d => d.php.drupalRules.computed))
|
|
files.push(['nginxconfig.io/drupal.conf', toConf(drupalConf(global))]);
|
|
|
|
// Drupal
|
|
if (domains.some(d => d.php.magentoRules.computed))
|
|
files.push(['nginxconfig.io/magento.conf', toConf(magentoConf())]);
|
|
|
|
}
|
|
|
|
return files;
|
|
};
|