Forum

[Request] Enable 'Include' inside VirtualHost

Mustafa Ramadhan
4 August 2014, 18:33
Hiawatha version: 9.7.b
Operating System: Centos 6

I found 'set' (like 'set var_user = apache') inside 'VirtualHost' but 'Include' will be appear 'Syntax Error' if declare inside 'VirtualHost'.

With this limitation, Hiawatha less flexible compare to Nginx.
Hugo Leisink
4 August 2014, 21:13
The usage of include inside a virtualhost, binding or other block is indeed not supported. I have no intention of changing this. Sorry.
Mustafa Ramadhan
5 August 2014, 08:08
Nginx and Lighttpd support 'set' and 'include' inside 'VirtualHost'. It's make simple switch from 'standard' to 'proxy' (let say nginx-proxy) without 're-create' whole web configs.

Imagine like this:

1. Config for certain domain:
VirtualHost {
set var_user = apache
Include /home/hiawatha/conf/globals/switch.conf
...
}


2. Config for fastcgi:
        ## taken 'var_user' from 'set'
UseFastCGI = php_for_var_user

UseToolkit = findindexfile


3. Config for proxy:
	ReverseProxy !\.(pl|cgi|py|rb|shmtl) http://127.0.0.1:30080/ 90 keep-alive

UseToolkit = findindexfile, permalink


So, switch from fastcgi to proxy just copy of proxy content to /home/hiawatha/conf/globals/switch.conf and then restart. The same way for switch from proxy to hiawatha.
Hugo Leisink
5 August 2014, 08:23
Ok, I'll take a look at it, no promises. But no changes for the next release.
Mustafa Ramadhan
9 August 2014, 06:57
Also, 'Include' under 'Include' not work.

Code inside '/etc/hiawatha/hiawatha.conf':
...
## including all file inside...
Include /home/hiawatha/conf/defaults
...


Code inside '/home/hiawatha/conf/defaults/init.conf':
...
## will be 'syntax error'; NOT under 'sections'
Include /home/hiawatha/conf/globals/virtualhost_cp.conf
...

Mustafa Ramadhan
9 August 2014, 09:10
It's possible 'include' under 'include' in apache, lighttpd and nginx.
Hugo Leisink
9 August 2014, 09:19
No includes in included files is done to prevent include-looping.
Mustafa Ramadhan
9 August 2014, 09:55
I am sure in apache/lighttpd/nginx, 'include in include' have limition. Let say, only permit 2 level/step.

I have a solution if hiawatha permit '2 level include' for easy to switch from fastcgi to proxy or vice versa.

In my test, this '2 level include' work perfectly for apache/lighttpd/nginx.
Hugo Leisink
9 August 2014, 23:04
Well, Hiawatha ain't Apache, Lighttpd or nginx. But I will take a look at it. Still, no promises.
This topic has been closed.