From b5d21c2b21cc1c19b29d3298d14f207ba910a31d Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 8 Aug 2021 01:03:50 +0000 Subject: httpd: set psgi.url_scheme to 'https' for TLS listeners For users using the native TLS functionality of -httpd (instead of using nginx + Plack::Middleware::ReverseProxy), psgi.url_scheme=http was wrong and would lead to improper redirects. --- lib/PublicInbox/HTTPD.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/HTTPD.pm b/lib/PublicInbox/HTTPD.pm index fb683f74..02f424c6 100644 --- a/lib/PublicInbox/HTTPD.pm +++ b/lib/PublicInbox/HTTPD.pm @@ -13,7 +13,7 @@ use PublicInbox::Daemon; sub pi_httpd_async { PublicInbox::HTTPD::Async->new(@_) } sub new { - my ($class, $sock, $app) = @_; + my ($class, $sock, $app, $client) = @_; my $n = getsockname($sock) or die "not a socket: $sock $!\n"; my ($host, $port) = PublicInbox::Daemon::host_with_port($n); @@ -23,7 +23,8 @@ sub new { SCRIPT_NAME => '', 'psgi.version' => [ 1, 1 ], 'psgi.errors' => \*STDERR, - 'psgi.url_scheme' => 'http', + 'psgi.url_scheme' => $client->can('accept_SSL') ? + 'https' : 'http', 'psgi.nonblocking' => Plack::Util::TRUE, 'psgi.streaming' => Plack::Util::TRUE, 'psgi.run_once' => Plack::Util::FALSE, -- cgit v1.2.3-24-ge0c7