1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Include INSIDE the authenticated logs.saikrupagas.com vhost in lighttpd-proxy,
# after its existing routing/authentication configuration. See deploy/README.md.
# Requires mod_access, mod_setenv and mod_proxy (after the auth modules).
# The private include defines var.superpulse.snipeit-token. Missing file/variable
# is a startup error, not an anonymous upstream request.
include "/etc/superpulse/snipeit.conf"
# Protect project configuration and the retired PHP endpoint/secret file.
$HTTP["url"] =~ "^/(?:deploy(?:/|$)|[.]env[.]php(?:/|$)|logs[.]php(?:/|$))" {
url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/api/devices(?:/|$)" {
# One device tag, GET only, no upstream query parameters or traversal.
$HTTP["url"] !~ "^/api/devices/[A-Za-z0-9_-][A-Za-z0-9_.-]*$" {
url.access-deny = ( "" )
}
$HTTP["request-method"] != "GET" {
url.access-deny = ( "" )
}
$HTTP["querystring"] != "" {
url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/api/devices/[A-Za-z0-9_-][A-Za-z0-9_.-]*$" {
# HTTP stays on loopback. Select Snipe-IT's vhost on the port-81 backend,
# not the Superpulse vhost (which would loop back into this route).
proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 81 )) )
proxy.header = (
"map-host-request" => ( "-" => "equipment.saikrupagas.com" ),
"map-urlpath" => ( "/api/devices/" => "/api/v1/hardware/bytag/" )
)
setenv.set-request-header += (
"Authorization" => "Bearer " + var.superpulse.snipeit-token,
"Accept" => "application/json"
)
setenv.set-response-header += (
"Cache-Control" => "no-store",
"Set-Cookie" => ""
)
}
}