Modifying <virtualHost>

Aza

Verified User
Joined
Feb 6, 2013
Messages
25
Location
Washington DC
"Admin Level -> Custom httpd configuration -> domain.com" allows admin to insert a line into the effective Virtual Host configuration

In the resulting panel, DirectAdmin cautions against replacing the entire "<Virtualhost>..</VirtualHost>" (sic), opining that admin should "[o]nly add the few lines of the VirtualHost you need to insert."

This begs two closely related questions:

1) There are multiple blocks, "IF" satements and the like in the VirtualHost specification. Obviously where a line is inserted will make a profound difference. Given no mechanism to direct where the new line will be inserted, what is the hapless admin supposed to do to get the desired result?

2) How can one edit the *existing* virtual host parameters without a conflict with DirectAdmin?

Is anyone here able to shed a bit of light on the intended solution?

Aza D. Oberman January 2017
 
Last edited:
Hello Aza,

Directadmin has at least 5 placeholders to add c custom code in httpd.conf and they are:

Code:
|CUSTOM1|
|CUSTOM|
|CUSTOM2|
|CUSTOM3|
|CUSTOM4|

each of them has its own position in the config. A template for analyzing can be found here: /usr/local/directadmin/data/templates/virtual_host2.conf Even simply add a line with "#" into each one in Directadmin interface, e.g.

Code:
#CUSTOM1
will go into textarea for CUSTOM1

Code:
#CUSTOM2
will go into textarea for CUSTOM2

and so on.

This won't break configuration but will show you where your code will be added.

So depending on where you need your code to be place choose the right CUSTOM token.


If you want to customize a single virtual host you can use Directadmin web-UI for this. If you want to do the same customization for all existing virtualhosts you can edit templates (but first copy them into the directory "custom"):

Code:
[COLOR=#000000][FONT=&quot]cd /usr/local/directadmin/data/templates/custom[/FONT][/COLOR]
[COLOR=#000000][FONT=&quot]cp ../virtual_host2.conf .

more reading:

[/FONT][/COLOR]https://help.directadmin.com/item.php?id=2[FONT=&quot]
[/FONT]
https://help.directadmin.com/item.php?id=214
 
Back
Top