]> Sergey Matveev's repositories - public-inbox.git/blob - examples/public-inbox.psgi
httpd: allow running if ReverseProxy is missing
[public-inbox.git] / examples / public-inbox.psgi
1 #!/usr/bin/perl -w
2 # Copyright (C) 2014-2015 all contributors <meta@public-inbox.org>
3 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
4 # Note: this is part of our test suite, update t/plack.t if this changes
5 # Usage: plackup [OPTIONS] /path/to/this/file
6 use strict;
7 use warnings;
8 use PublicInbox::WWW;
9 PublicInbox::WWW->preload;
10 use Plack::Request;
11 use Plack::Builder;
12 my $www = PublicInbox::WWW->new;
13 builder {
14         enable 'Chunked';
15         eval {
16                 enable 'Deflater',
17                         content_type => [ qw(
18                                 text/html
19                                 text/plain
20                                 application/atom+xml
21                                 )]
22         };
23         $@ and warn
24 "Plack::Middleware::Deflater missing, bandwidth will be wasted\n";
25         # Enable to ensure redirects and Atom feed URLs are generated
26         # properly when running behind a reverse proxy server which
27         # sets X-Forwarded-For and X-Forwarded-Proto request headers.
28         # See Plack::Middleware::ReverseProxy documentation for details
29         eval { enable 'ReverseProxy' };
30         $@ and warn
31 "Plack::Middleware::ReverseProxy missing,\n",
32 "URL generation for redirects may be wrong if behind a reverse proxy\n";
33
34         enable 'Head';
35         sub { $www->call(@_) };
36 }