[Dancer-users] Redirects on https:// sites

Stefan Hornburg (Racke) racke at linuxia.de
Tue May 3 21:15:17 CEST 2011


On 05/02/2011 09:52 AM, Stefan Hornburg (Racke) wrote:
> Hello, fellow dancers!
>
> I got a simple, Dropbox-alike Dancer application in the works. The site
> is running on https:// with Perlbal, Starman and started with plackup.
>
> Any relative redirects like redirect 'login' are pointing to http://
> instead of https://.
>
> What could be the reason?
>

OK, figured it out with the help of #dancer IRC channel, thanks to
miyagawa and bigpresh.

Here's the summary for the archives.

Perlbal serves as reverse proxy on https://, but Plack is running
on http://127.0.0.1:5000/.

This is the https::// configuration for Perlbal:

# HTTPS selector
CREATE SERVICE dropbox_ssl_selector
  SET listen              = 192.168.0.19:443
  SET role                = selector
  SET plugins             = vpaths
  SET enable_ssl          = on
  SET ssl_key_file        = /etc/ssl/private/ssl-cert.key
  SET ssl_cert_file       = /etc/ssl/certs/ssl-cert.pem
  VPATH .*                = web_prod
ENABLE dropbox_ssl_selector
HEADER dropbox_ssl_selector INSERT X-Forwarded-Proto: HTTPS

The trick to pass the protocol into the dancer application is to
use Plack::Middleware::ReverseProxy as follows:

builder {
       enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' }
           "Plack::Middleware::ReverseProxy";
       $app;
   };

Regards
	Racke

-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team



More information about the Dancer-users mailing list