Feature #1313
closedAllow conditional config based on local IP and port
Description
$HTTP["localip"] == "192.168.0.1" { # config that is shared by both HTTP and HTTPS on this interface } $HTTP["port"] == "443" { # all SSL sites }
I think we cannot do this using $SERVERsocket without massively duplicating the configs.
Updated by darix over 17 years ago
- Status changed from New to Fixed
- Resolution set to invalid
you dont have to duplicate stuff. you just put them into a seperate file and use:
include "sharedconfig.conf"
Updated by at2000 over 17 years ago
- Status changed from Fixed to Need Feedback
- Resolution deleted (
invalid)
OK, you got a valid workaround to avoid duplication of config, but I am not convinced that this is the more preferred way than the features I asked for.
It is common to have some rules shared by both http and https, e.g. both forward to the same fastcgi connection. It is also common to have some rules shared by all https connections, e.g. enabling the ssl backend and implementing those IE and Opera SSL hacks.
Are we satisfied with moving each of these configs to a separate file "as the ultimate solution"?
Updated by darix over 17 years ago
you can do that already
$HTTPhost is evaluate within https hosts too.
sadly it has downsides.
Updated by at2000 over 17 years ago
$HTTP[ "host" ] can partly replace $HTTP[ "localip" ], but again we may got different "Host:" headers even on the same interface, most notably being both the IP address and the domain name pointing thereto.
I am not sure how difficult it is to write the code, but from a user point of view I think it is a useful feature, especially it completes the missing pieces in writing conditionals.
Updated by at2000 about 17 years ago
The recently added $HTTPscheme is one step forward towards this direction. Users simply want at least (if not more than) one way to achieve their configuration needs, instead of being forced to use hacks.
Updated by gstrauss over 8 years ago
- Description updated (diff)
- Status changed from Need Feedback to Wontfix
Using $HTTP["scheme"] is the recommended way to differentiate http and https
Using $HTTP["host"] =~ "^(host1\.com|host2\.com|host3\.com)$" is one way to apply common config to multiple hosts.
Another way is to put the common config into an include file, and to include that within each $HTTP["host"] which should have that common config.
While there could, of course, be more and better ways to group and share configs, doing so by local IP would be one of the more expensive ways to do so. If there is only one listening IP on the machine, then $SERVER["socket"] condition can contain the shared config. If there are multiple IPs and they are not differentiated by multiple $SERVER["socket"] directives (which could contain config for that local IP), then lighttpd would need to call getsockname() to get the actual local IP address of the connection, and then handle IPv4, IPv6, unix domain socket formats for comparison to the local IP address that was given in the config file.
Also available in: Atom