Repository: digitalocean/nginxconfig.io
File: src/nginxconfig/generators/conf/website.conf.js (JavaScript)

Code before:

        // Add the redirect config to the parent config now its built
        config.push([`# ${domain.server.wwwSubdomain.computed ? 'non-www, ' : ''}subdomains redirect`, '']);
        config.push(['server', redirectConfig]);
    }

    // HTTP redirect
    if (domain.https.forceHttps.computed) {
        // Add the redirect config to the parent config now its built
        config.push(['# HTTP redirect', '']);
        if (domain.server.wwwSubdomain.computed && !domain.server.redirectSubdomains.computed) {
            config.push(['server', httpRedirectConfig(domain, global, domain.server.domain.computed, `www.${domain.server.domain.computed}`)]);
            config.push(['server', httpRedirectConfig(domain, global, `www.${domain.server.domain.computed}`)]);
        } else if (!domain.server.wwwSubdomain.computed && !domain.server.redirectSubdomains.computed) {
            config.push(['server', httpRedirectConfig(domain, global, domain.server.domain.computed)]);
        }
        if (domain.server.cdnSubdomain.computed) {
            config.push(['server', httpRedirectConfig(domain, global, `cdn.${domain.server.domain.computed}`)]);
        }
        if (domain.server.redirectSubdomains.computed) {
            config.push(['server', httpRedirectConfig(domain, global, `.${domain.server.domain.computed}`, `${domain.server.wwwSubdomain.computed ? 'www.' : '' }${domain.server.domain.computed}`)]);
        }
    }

    // Security.txt
    if(global.security.securityTxt.computed){
        config.push(['# security.txt', '']);
        config.push(['location /security.txt', {
            return: `301 http://${domain.server.wwwSubdomain.computed ? 'www.' : ''}${domain.server.domain.computed}/.well-known/security.txt`,
        }]);
        
        // Custom security.txt path
        config.push(['location = /.well-known/security.txt', {
            alias: `${global.security.securityTxtPath.value}`,
        }]);
    }

    return config;
};


Review comment (security):
```suggestion
    if (global.security.securityTxt.computed) {
```
Formatting

Code after:

        // Add the redirect config to the parent config now its built
        config.push([`# ${domain.server.wwwSubdomain.computed ? 'non-www, ' : ''}subdomains redirect`, '']);
        config.push(['server', redirectConfig]);
    }

    // HTTP redirect
    if (domain.https.forceHttps.computed) {
        // Add the redirect config to the parent config now its built
        config.push(['# HTTP redirect', '']);
        if (domain.server.wwwSubdomain.computed && !domain.server.redirectSubdomains.computed) {
            config.push(['server', httpRedirectConfig(domain, global, domain.server.domain.computed, `www.${domain.server.domain.computed}`)]);
            config.push(['server', httpRedirectConfig(domain, global, `www.${domain.server.domain.computed}`)]);
        } else if (!domain.server.wwwSubdomain.computed && !domain.server.redirectSubdomains.computed) {
            config.push(['server', httpRedirectConfig(domain, global, domain.server.domain.computed)]);
        }
        if (domain.server.cdnSubdomain.computed) {
            config.push(['server', httpRedirectConfig(domain, global, `cdn.${domain.server.domain.computed}`)]);
        }
        if (domain.server.redirectSubdomains.computed) {
            config.push(['server', httpRedirectConfig(domain, global, `.${domain.server.domain.computed}`, `${domain.server.wwwSubdomain.computed ? 'www.' : '' }${domain.server.domain.computed}`)]);
        }
    }

    return config;
};