Skip to content

Commit

Permalink
reverse proxy support is now also available for PSGI
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 12, 2014
1 parent 295b939 commit d97002a
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,5 +1,5 @@

5.13 2014-07-12
5.13 2014-07-13
- Added json_like, json_message_like, json_message_unlike and json_unlike
methods to Test::Mojo.
- Improved HTML5.1 compliance of Mojo::DOM::HTML.
Expand Down
8 changes: 6 additions & 2 deletions lib/Mojolicious/Guides/Cookbook.pod
Expand Up @@ -226,18 +226,22 @@ Python's WSGI and Ruby's Rack. L<Mojolicious> applications are ridiculously
simple to deploy with L<Plack>.

$ plackup ./script/myapp
HTTP::Server::PSGI: Accepting connections at http://0:5000/

L<Plack> provides many server and protocol adapters for you to choose from,
such as C<FCGI>, C<uWSGI> and C<mod_perl>.

$ plackup ./script/myapp -s FCGI -l /tmp/myapp.sock

The C<MOJO_REVERSE_PROXY> environment variable can be used to enable proxy
support, this allows L<Mojolicious> to automatically pick up the
C<X-Forwarded-For> and C<X-Forwarded-Proto> headers.

$ MOJO_REVERSE_PROXY=1 plackup ./script/myapp

If an older server adapter is not be able to correctly detect the application
home directory, you can simply use the C<MOJO_HOME> environment variable.

$ MOJO_HOME=/home/sri/myapp plackup ./script/myapp
HTTP::Server::PSGI: Accepting connections at http://0:5000/

There is no need for a C<.psgi> file, just point the server adapter at your
application script, it will automatically act like one if it detects the
Expand Down
2 changes: 1 addition & 1 deletion t/mojo/cgi.t
Expand Up @@ -43,7 +43,7 @@ get '/proxy' => sub {
# Reverse proxy
{
ok !Mojo::Server::CGI->new->reverse_proxy, 'no reverse proxy';
local $ENV{MOJO_REVERSE_PROXY} = 25;
local $ENV{MOJO_REVERSE_PROXY} = 1;
ok !!Mojo::Server::CGI->new->reverse_proxy, 'reverse proxy';
}

Expand Down
2 changes: 1 addition & 1 deletion t/mojo/daemon.t
Expand Up @@ -41,7 +41,7 @@ use Mojolicious;
# Reverse proxy
{
ok !Mojo::Server::Daemon->new->reverse_proxy, 'no reverse proxy';
local $ENV{MOJO_REVERSE_PROXY} = 25;
local $ENV{MOJO_REVERSE_PROXY} = 1;
ok !!Mojo::Server::Daemon->new->reverse_proxy, 'reverse proxy';
}

Expand Down
2 changes: 1 addition & 1 deletion t/mojo/psgi.t
Expand Up @@ -37,7 +37,7 @@ get '/proxy' => sub {
# Reverse proxy
{
ok !Mojo::Server::PSGI->new->reverse_proxy, 'no reverse proxy';
local $ENV{MOJO_REVERSE_PROXY} = 25;
local $ENV{MOJO_REVERSE_PROXY} = 1;
ok !!Mojo::Server::PSGI->new->reverse_proxy, 'reverse proxy';
}

Expand Down

0 comments on commit d97002a

Please sign in to comment.