|DirectAdmin offers a huge variety of ways to customize your User's VirtualHost entries.|
This guide will help you pick which method to use depending on what you need it to do.
To aid in speeding up paths, should you know what you want to use, enter the info here:
There are 3 major sections to consider when deciding which method to use:
Raw TemplatesThese are located in
/usr/local/directadmin/data/templates/and we typically discourage relying on custom versions of these in case we make important changes to them, in which case you wouldn't get them. In some cases, you will need to do use a custom copy, but only if none of the options below work for you. The typically 4 template in question would be:
#Apache 2.xbut varies if you're using other server types.
openlitespeed_vhost.conf #combined for all 4
Per-Domain with the CUSTOM tokens via "Custom Httpd Config"This Admin Level area lets you insert code into any CUSTOM or CUSTOM# token point for all VirtualHosts in that domain, including http+https for both domains and subdomains.
This method is used only when you want to change a setting just for this domain.
This GUI tool saves files to disk (depening on the token name), eg:
... #CUSTOM2, etc.
- This tool is used to inset token variables where applicable. You're not saving a file for each CUSTOM token name, but can create the mentioned file below to pre-load some tokens. This will allow you to set tokens before anything other CUSTOM tokens are set (it's not for code itself, just setting variables). See this guide on how to set a token with the |?TOKENNAME=value| syntax. Token variables can be used within a value eg:
|?TOKENNAME=value of `OTHERTOKEN`|The files available to load in your custom tokens of various levels:
/usr/local/directadmin/data/admin/global_httpd_tokens.conf #globalwhere "httpd_tokens" is the name used, regardless of server type (httpd/nginx/litespeed/openlitespeed).
/usr/local/directadmin/data/users/fred/domains/fred.com.httpd_tokens #per domain
/usr/local/directadmin/data/users/fred/domains/fred.com.sub.httpd_tokens #per domain
This is independent of the template name, so these tokens will be loaded into all of the 4 virtual_host2*.conf templates mentioned above.
Global VirtualHost Pre/PostThese template depend on the "Template Name" above, so preset that if you're trying to sort out which to use.
Using these files will write the given code into the User's httpd.conf either before or after, outside of the VirtualHost tag, for any use of the given template file.
Paths can be either:
/usr/local/directadmin/data/templates/custom/virtual_host2.conf.preThis took might be handy if you want to insert a https://webmail.domain.com VH (eg: you'd use the /usr/local/directadmin/data/templates/custom/virtual_host2_secure.conf.post, so it only gets added once per domain, only for https)
Global Token name per file, pre/postSimilar to the global CUSTOM tokens, this lets you control only which template it goes with. Your code will be inserted either before or after any use of the given CUSTOM* tokens. For example, if you use the pre variant, this code is inserted before say, per-domain CUSTOM inserted code. Possible files might be:
Global CUSTOM token, regardless of filenameThis one is related to the global tokens, except you can use this for actual code, as it's injected in a specific order. Applies to all template files. Possible files include
/usr/local/directadmin/data/templates/custom/cust_httpd.CUSTOM.pretaking note how the numbered tokens have a dot between CUSTOM and the number.
... CUSTOM.2.pre ... etc.
Note: for almost all areas, you can use if-then-else syntax and set variables which carry forward within that template.