about summary refs log tree commit homepage
path: root/lib/PublicInbox/HTTPD.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-08-08 01:03:50 +0000
committerEric Wong <e@80x24.org>2021-08-08 01:17:20 +0000
commitb5d21c2b21cc1c19b29d3298d14f207ba910a31d (patch)
tree4c428b6ca9f5eb0b66337d63305c7938c62dd561 /lib/PublicInbox/HTTPD.pm
parent5d3e9705c8d5a6d0341a5f1bed2027ef9f9e95a8 (diff)
downloadpublic-inbox-b5d21c2b21cc1c19b29d3298d14f207ba910a31d.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/HTTPD.pm')
-rw-r--r--lib/PublicInbox/HTTPD.pm5
1 files changed, 3 insertions, 2 deletions
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,