Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"

Top Level » Apache Related Information

CUSTOM HTTPD TEMPLATES: Starting pointLast Modified: Nov 18, 2019, 4:24 pm
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:

Template Name:See #1 for options
Server Type:or: cust_nginx, cust_openlitespeed
Token Name:or: CUSTOM1, CUSTOM2, etc.

There are 3 major sections to consider when deciding which method to use:
  1. Raw Templates

    These are located in


    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.x


    openlitespeed_vhost.conf #combined for all 4

    but varies if you're using other server types.
  2. 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:

    /usr/local/directadmin/data/users/fred/domains/     #CUSTOM
    /usr/local/directadmin/data/users/fred/domains/   #CUSTOM1
    ... #CUSTOM2, etc.

  3. Tokens for Global, Per-User, Per-Domain

    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 #global
    /usr/local/directadmin/data/users/fred/domains/ #per domain
    /usr/local/directadmin/data/users/fred/domains/ #per domain

    where "httpd_tokens" is the name used, regardless of server type (httpd/nginx/litespeed/openlitespeed).
    This is independent of the template name, so these tokens will be loaded into all of the 4 virtual_host2*.conf templates mentioned above.
  4. Global VirtualHost Pre/Post

    These 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:


    This took might be handy if you want to insert a VH (eg: you'd use the /usr/local/directadmin/data/templates/custom/, so it only gets added once per domain, only for https)
  5. Global Token name per file, pre/post

    Similar 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:


  6. Global CUSTOM token, regardless of filename

    This 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

    ... CUSTOM.2.pre ... etc.

    taking note how the numbered tokens have a dot between CUSTOM and the number.

Note: for almost all areas, you can use if-then-else syntax and set variables which carry forward within that template.

Related Helpfiles

© 2018 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST