]> Sergey Matveev's repositories - public-inbox.git/blobdiff - examples/public-inbox.psgi
examples/public-inbox.psgi: document ReverseProxy
[public-inbox.git] / examples / public-inbox.psgi
index 04f3329a973816e0ff4ba20f799ce85e29c04725..c4a8903e1639e2a101b2ea919058d0c9b2b7897e 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/perl -w
-# Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
+# Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
 # Note: this is part of our test suite, update t/plack.t if this changes
 # Usage: plackup [OPTIONS] /path/to/this/file
@@ -9,11 +9,22 @@ use PublicInbox::WWW;
 PublicInbox::WWW->preload;
 use Plack::Request;
 use Plack::Builder;
+my $have_deflater = eval { require Plack::Middleware::Deflater; 1 };
+
 builder {
-       enable "Deflater",
-               content_type => [ 'text/html', 'text/plain',
-                               'application/atom+xml' ];
-       enable "Head";
+       enable 'Chunked';
+       if ($have_deflater) {
+               enable 'Deflater',
+                       content_type => [ 'text/html', 'text/plain',
+                                       'application/atom+xml' ];
+       }
+
+       # Enable to ensure redirects and Atom feed URLs are generated
+       # properly when running behind a reverse proxy server which
+       # sets X-Forwarded-For and X-Forwarded-Proto request headers.
+       # See Plack::Middleware::ReverseProxy documentation for details
+       # enable 'ReverseProxy';
+       enable 'Head';
        sub {
                my $req = Plack::Request->new(@_);
                PublicInbox::WWW::run($req, $req->method);