Variable substitution in e-smith template

NethServer Version: 7.9.2009
Module: WebServer

I need some extra Lines in just one of my reverse proxies:

RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule /notifications/hub(.*) ws://<DESTINATION_IP>:3012/$1 [P,L]
RequestHeader set X-Real-IP <NETHSERVER_IP>

For vhosts I had the same need and solved it via:

/etc/e-smith/templates-custom/httpd/vhost-extra/16matrix_redirect

{
$OUT = ‘’;
if( $ServerName eq ‘<MY.FQDN>’ && $Port == 443) {
$OUT .= <<REDIRECT;
# Here are
# The extra lines
# just for MY.FQDN on port 443
REDIRECT
} else {
$OUT = ‘’;
}
}

so I tried the same with

/etc/e-smith/templates-custom/httpd/proxy-extra/30ProxyPass

and in there a similar condition
(ANOTHER.FQDN is reverse proxy created via cockpit)

if( $ServerName eq ‘<ANOTHER.FQDN>’ && $Port == 443) { }

but this condition is never true.
Are there other variable names in proxy-extra then in vhost-extra ?

As a test I just wrote $ServerName and $Port to all my reverse proxies via that method.
The do not get substituted and are inserted to virtualhosts.conf as strings.

THX for a hint to the right direction / documentation
Tom

@support_team
Can somebody help?

1 Like

A blind shot on your need, if you just need to customise one of your proxypass, why to not simply write a /etc/httpd/conf.d/myProxy.conf file with what you need, copy and paste the relevant part of the workable proxy to this.

It is better because a custom-template won’t ever be updated when I will push changes to it. Said by another manner, a custom-template is a good way to break your system.

1 Like

Thank you Stéphane - I did not think about the easy way :slight_smile:
Will simply create the config direct.