diff --git a/src/nginxconfig/generators/conf/website.conf.js b/src/nginxconfig/generators/conf/website.conf.js index 1d67aef..f08cb9a 100644 --- a/src/nginxconfig/generators/conf/website.conf.js +++ b/src/nginxconfig/generators/conf/website.conf.js @@ -301,7 +301,7 @@ export default (domain, domains, global, ipPortPairs) => { if (!domain.https.forceHttps.computed && domain.https.certType.computed === 'letsEncrypt') serverConfig.push(['include', 'nginxconfig.io/letsencrypt.conf']); - if (domain.php.wordPressRules.computed) serverConfig.push(['include', 'nginxconfig.io/wordpress.conf']); + if (domain.php.wordPressRules.computed) serverConfig.push(['include', `nginxconfig.io/${domain.server.domain.computed}.wordpress.conf`]); if (domain.php.drupalRules.computed) serverConfig.push(['include', 'nginxconfig.io/drupal.conf']); if (domain.php.magentoRules.computed) serverConfig.push(['include', 'nginxconfig.io/magento.conf']); if (domain.php.joomlaRules.computed) serverConfig.push(['include', 'nginxconfig.io/joomla.conf']); @@ -312,7 +312,7 @@ export default (domain, domains, global, ipPortPairs) => { if (!domain.https.forceHttps.computed && domain.https.certType.computed === 'letsEncrypt') serverConfig.push(...Object.entries(letsEncryptConf(global))); - if (domain.php.wordPressRules.computed) serverConfig.push(...Object.entries(wordPressConf(global))); + if (domain.php.wordPressRules.computed) serverConfig.push(...Object.entries(wordPressConf(global, domain))); if (domain.php.drupalRules.computed) serverConfig.push(...Object.entries(drupalConf(global))); if (domain.php.magentoRules.computed) serverConfig.push(...Object.entries(magentoConf())); if (domain.php.joomlaRules.computed) serverConfig.push(...Object.entries(joomlaConf())); diff --git a/src/nginxconfig/generators/conf/wordpress.conf.js b/src/nginxconfig/generators/conf/wordpress.conf.js index e0246fa..1c8e2b0 100644 --- a/src/nginxconfig/generators/conf/wordpress.conf.js +++ b/src/nginxconfig/generators/conf/wordpress.conf.js @@ -24,7 +24,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -export default global => { +import phpPath from '../../util/php_path'; +import phpUpstream from '../../util/php_upstream'; + +export default (global, domain) => { const config = {}; config['# WordPress: allow TinyMCE'] = ''; @@ -61,6 +64,10 @@ export default global => { limit_req: 'zone=login burst=2 nodelay', include: 'nginxconfig.io/php_fastcgi.conf', }; + if (domain.php.wordPressRules.computed) { + config['location = /wp-login.php'].fastcgi_pass = domain.php.phpBackupServer.computed !== '' + ? phpUpstream(domain) : phpPath(domain); + } } // Done! diff --git a/src/nginxconfig/generators/index.js b/src/nginxconfig/generators/index.js index 0479b29..548e02a 100644 --- a/src/nginxconfig/generators/index.js +++ b/src/nginxconfig/generators/index.js @@ -61,6 +61,9 @@ export default (domains, global) => { const ipPortPairs = new Set(); for (const domain of domains) { files[`${sitesDir}/${domain.server.domain.computed}.conf`] = toConf(websiteConf(domain, domains, global, ipPortPairs)); + // WordPress + if (domains.some(d => d.php.wordPressRules.computed)) + files[`nginxconfig.io/${domain.server.domain.computed}.wordpress.conf`] = toConf(wordPressConf(global, domain)); } // Let's encrypt @@ -85,10 +88,6 @@ export default (domains, global) => { if (domains.some(d => d.reverseProxy.reverseProxy.computed)) files['nginxconfig.io/proxy.conf'] = toConf(proxyConf(global)); - // WordPress - if (domains.some(d => d.php.wordPressRules.computed)) - files['nginxconfig.io/wordpress.conf'] = toConf(wordPressConf(global)); - // Drupal if (domains.some(d => d.php.drupalRules.computed)) files['nginxconfig.io/drupal.conf'] = toConf(drupalConf(global));