Monday, September 21, 2015

linux - Redirect all http & https requests with lighttpd

I have a spare Raspberry Pi so I decided to check out PirateBox.



I have it all working however the default behaviour is to not redirect https requests. Given the PirateBox will be never connected to the Internet and people connecting most likely won't know the address to request, I would like to redirect all requests (http & https) to the PirateBox Uri, piratebox.lan




I would like to set it up to be similar to a captive portal but I don't need authentication and the requests will always be redirected



PirateBox uses Arch Linux with dnsmasq and lighttpd.
My current setting are



/etc/dnsmasq.conf



address=/#/192.168.77.1



/opt/piratebox/conf/lighttpd/lighttpd.conf



$HTTP["host"] !~ "^piratebox\.lan.*$" {
url.redirect = ( "^/(.*)$" => "http://piratebox.lan/redirect.html" )
}

$SERVER["socket"] == ":443" {
$HTTP["host"] !~ "^piratebox\.lan.*$" {
url.redirect = ( "^/(.*)$" => "http://piratebox.lan/redirect.html" )
}

}

$SERVER["socket"] == ":80" {
$HTTP["host"] !~ "^piratebox\.lan.*$" {
url.redirect = ( "^/(.*)$" => "http://piratebox.lan/redirect.html")
}
}


While all http requests are redirected to the PirateBox page, https requests aren't redirected and the PirateBox page isn't loaded, it just times out.




What am I doing wrong or should I approach this is a different way?



Update
I have also tried



$HTTP["scheme"] == "https" {
url.redirect = ( "^/(.*)$" => "http://piratebox.lan/redirect.html" )
}



and it doesn't work either

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...