1

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

  • Have you seen this http://serverfault.com/a/450408 ? And especially the part about browsers not redirecting to http once a connection has been established in https – Toine42 Jun 05 '15 at 06:58
  • Try [mod-rewrite](http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_ModRewrite) .... [source](http://redmine.lighttpd.net/boards/2/topics/1341) – mk117 Jun 07 '15 at 06:19

1 Answers1

1

I don't have a lot of experience with lighttpd itself, but from the semantics of the config file, it seems to me, that if you have a connection coming in on port 443, it will redirect to port 443 regardless if you specify http:// in the URL or not. If I understand correctly and you want to redirect to port 80, you need to specify it explicitly in the directive:

url.redirect = ( "^/(.*)$" => "http://piratebox.lan:80/redirect.html" )
taskalman
  • 11
  • 3
  • Unfortunately that doesn't work. I would expect the default port of 80 to be used for the redirect. As a side note, the https request seems to time out like https traffic makes it to lighttpd. – TheLukeMcCarthy Jun 03 '15 at 19:59