Custom nginx.conf files

eknip

Verified User
Joined
Jul 29, 2009
Messages
21
I've searched in the forum but haven't found an answer or solution, so thought I'd open a new thread for this.

I have several domainnames that have a (highly) customized nginx.conf file. I know that as admin in DA there's the "Custom HTTPD Configurations" option, but this only gives the possibility to change document roots etc, not add extra blocks within the nginx.conf file (as far as I'm aware).

Another option would be to modify the nginx_server.conf and nginx_server_secure.conf templates with IF/THEN/ELSE statements for each domain, but it would become a huge messy template.

So my question is, is there another (better) solution for per-domain or per-user nginx.conf files?

Thanks in advance!
 
Customize HTTPd configuration allows you to add any custom code, not just change the docroot :)
 
Tnx! So what's the best way to do this with a domain that has an SSL certificate installed and therefor 2 different server blocks? Since it specifically mentions to not add a whole server { ... } entry. I have one server block that redirects to HTTPS:

Code:
server
{
    listen 85.17.189.102:80;
    server_name domain.com [url]www.domain.com[/url] ;
    rewrite ^ https://$server_name$request_uri? permanent;
}

And in the other (HTTPS) server block I have the custom configuration(s). I'm not sure about this so hope you can point me a bit more in the right direction.

Thanks again!
 
For your exact case, if you only need to add that 1 line to the non-SSL host, you could add this check to:
Admin Level -> Custom Httpd Config
Code:
|?MYDOCROOT=`HOME`/domains/`DOMAIN`/public_html|
|*if DOCROOT=MYDOCROOT|
        rewrite ^ https://$server_name$request_uri? permanent;
|*endif|
which would add the line only to the main http://domain.com on port 80, since we check to see if the document root is the default public path.

On a side-note, I've just added this code, which would make this easier in the future:
https://www.directadmin.com/features.php?id=1626

John
 
Thanks.

For your exact case, if you only need to add that 1 line to the non-SSL host, you could add this check to:
Admin Level -> Custom Httpd Config
Code:
|?MYDOCROOT=`HOME`/domains/`DOMAIN`/public_html|
|*if DOCROOT=MYDOCROOT|
        rewrite ^ https://$server_name$request_uri? permanent;
|*endif|
which would add the line only to the main http://domain.com on port 80, since we check to see if the document root is the default public path.

On a side-note, I've just added this code, which would make this easier in the future:
https://www.directadmin.com/features.php?id=1626

John

This is what I was looking.

Thanks you very much.
 
Back
Top