mirror of
				https://github.com/digitalocean/nginxconfig.io.git
				synced 2025-11-04 18:28:17 +08:00 
			
		
		
		
	Fix limit_req and Wordpress-specific breaking wp-login.php (#360)
* limit_req and Wordpress-specific rules break wp-login.php issue #350 fix * config for user's selection for php server * comment fixes * eslint fixes Co-authored-by: Aman Agarwal <aman@Amans-MacBook-Air.local>
This commit is contained in:
		@@ -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()));
 | 
			
		||||
 
 | 
			
		||||
@@ -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!
 | 
			
		||||
 
 | 
			
		||||
@@ -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));
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user