Custom templates vhosts

RaZer0r

Verified User
Joined
Sep 14, 2007
Messages
62
Hi,

I'm currently using a custom template to enable one user to bypass my varnish reverse proxy because he's backend control panel is getting some 503 issues. This is of course a temporary solution as varnish is getting some issues here.

Now a second user who is using some POST cmd to create a pdf is experiencing a 503 error.
When using the apache port 8080 (varnish is running on the same host, on port 80) the pdf shows up fine, and a download prompt is being summoned.

Now, until I get the time to fix these both things I want to make sure this user also is able to get the straight apache bypass as user A.

What I did:
Apache listens on: port yy.yy.yy.yy:8080 (global) and xx.xx.xx.xx:80 for user A
Varnish listens on yy.yy.yy.yy:80

As a custom template I inserted the following to make directadmin rewrite properly:
Code:
|*if USER="username"|
<VirtualHost |IP|:80 |MULTI_IP|>
|*else|
<VirtualHost |IP|:8080 |MULTI_IP|>
|*endif|

What I want to do is use a second username to be in the list to make sure his config will be rewritten properly too (thus: |IP|:80 instead of |IP|:8080)
And assign the ip xx.xx.xx.xx to this users too.

Anyone who can help me out?

What is this *if *else *endif thing directadmin is using to rewrite? I tried common bash stuff to try to get it to if elseif end and so on, but nothing seems to work.
 
I will reply the code thing in PHP;

PHP:
<?
if($user=="username")
{
  print '<VirtualHost |IP|:80 |MULTI_IP|>';
}
else
{
  print '<VirtualHost |IP|:8080 |MULTI_IP|>';
}
?>

If the user = username then it will do the first VirtualHost, if that doesn't match then it will do VirtualHost with 8080.

So far I can see it should be okay
 
Last edited:
Well, that is true, but can directadmin handle php templates?

i'm looking for a structure like this in bash:

if [ expression ]
then
commands
elif [ expression2 ]
then
commands
else
commands
fi

so that I can have more than one user in the exception list.

With kind regards,

Rein
 
check help.directadmin.com or directadmin.com/versions.php
 
What I want to do is use a second username to be in the list to make sure his config will be rewritten properly too (thus: |IP|:80 instead of |IP|:8080)

And doesn't it work as expected?

Well, that is true, but can directadmin handle php templates?

Nope, as far as I know.

I would use a custom token in a template, in a case your method does not work. Something like:

Code:
|?USER_PORT=80|
<VirtualHost |IP|:|USER_PORT| |MULTI_IP|>

so you would be able to redefine token on your Httpd.conf Customization page for a specified domain in directadmin:

Code:
|?USER_PORT=8080|

N.B. I did not check my possible solution, you should verify that it works before.
 
finally I found some real easy solution, and i'm slamming my head against the door for not seeing this earlier :p.

I just used an if IP="xx.xx.xx.xx" statement to see if port 80 or port 8080 needed to be put in the user's httpd.conf

that way I could just give all the users that need a different port to dedicate the ip they need to match that rule.

Man, I'm glad I finally got this working as it should :p.
BTW I tried to go on the custom token route, but got stuck when the new variable was assigned.

anyhow, nice workaround ;)
 
Back
Top