Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

removed X-Forwarded-Host support since it is redundant for well confi…

…gured reverse proxies
  • Loading branch information...
commit f2dec76039b783e9c49c9682c05c4c2c242b85d7 1 parent f77e184
@kraih authored
View
2  Changes
@@ -1,6 +1,8 @@
This file documents the revision history for Perl extension Mojolicious.
2.69 2012-03-26
+ - Removed X-Forwarded-Host support since it is redundant for well
+ configured reverse proxies.
- Changed number of redirects ojo and the get command will follow to 10.
- Improved ojo to detect proxy servers automatically.
- Improved Mojo::DOM::CSS performance.
View
17 lib/Mojo/Message/Request.pm
@@ -148,20 +148,9 @@ sub parse {
}
}
- # Reverse proxy
- if ($ENV{MOJO_REVERSE_PROXY}) {
-
- # "X-Forwarded-Host"
- if (my $host = $headers->header('X-Forwarded-Host')) {
- if ($host =~ $HOST_RE) {
- $base->host($1);
- $base->port($2) if defined $2;
- }
- }
-
- # "X-Forwarded-HTTPS"
- $base->scheme('https') if $headers->header('X-Forwarded-HTTPS');
- }
+ # "X-Forwarded-HTTPS"
+ $base->scheme('https')
+ if $ENV{MOJO_REVERSE_PROXY} && $headers->header('X-Forwarded-HTTPS');
}
return $self;
View
2  lib/Mojolicious/Guides/Cookbook.pod
@@ -100,7 +100,7 @@ single incoming connection, just by running the command above again.
You might also want to enable proxy support if you're using Hypnotoad behind
a reverse proxy. This allows L<Mojolicious> to automatically pick up the
-C<X-Forwarded-For>, C<X-Forwarded-Host> and C<X-Forwarded-HTTPS> headers.
+C<X-Forwarded-For> and C<X-Forwarded-HTTPS> headers.
# myapp.conf
{hypnotoad => {proxy => 1}};
View
1  lib/Mojolicious/Plugin/HeaderCondition.pm
@@ -68,7 +68,6 @@ Mojolicious::Plugin::HeaderCondition - Header condition plugin
get '/' => (agent => qr/Firefox/) => sub {...};
# The "host" condition is a shortcut for the detected host
- # (usually the "Host" or "X-Forwarded-Host" header)
get '/' => (host => qr/mojolicio\.us/) => sub {...};
=head1 DESCRIPTION
View
28 t/mojolicious/embedded_lite_app.t
@@ -9,7 +9,7 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}
-use Test::More tests => 125;
+use Test::More tests => 116;
use FindBin;
use lib "$FindBin::Bin/lib";
@@ -249,36 +249,10 @@ too!works!!!
</form>
EOF
-# GET / (full external application with domain and reverse proxy)
-{
- local $ENV{MOJO_REVERSE_PROXY} = 1;
- $t->get_ok('/' => {'X-Forwarded-Host' => 'mojolicious.org'})->status_is(200)
- ->content_is(<<'EOF');
-works!
-
-too!works!!!
-<form action="/%E2%98%83">
- <input type="submit" value="☃" />
-</form>
-EOF
-}
-
# GET /host (full external application with domain)
$t->get_ok('/host' => {Host => 'mojolicious.org'})->status_is(200)
->content_is('mojolicious.org');
-# GET /host (full external application with domain and reverse proxy)
-{
- local $ENV{MOJO_REVERSE_PROXY} = 1;
- $t->get_ok('/host' => {'X-Forwarded-Host' => 'mojolicious.org'})
- ->status_is(200)->content_is('mojolicious.org');
-}
-
-# GET /host (full external application with domain and no reverse proxy)
-$t->get_ok(
- '/host' => {Host => 'mojolicious.org', 'X-Forwarded-Host' => 'kraih.com'})
- ->status_is(200)->content_is('mojolicious.org');
-
# GET / (full external application with domain)
$t->get_ok('/' => {Host => 'mojolicio.us'})->status_is(200)
->content_is(<<'EOF');
View
29 t/mojolicious/lite_app.t
@@ -9,7 +9,7 @@ BEGIN {
$ENV{MOJO_REACTOR} = 'Mojo::Reactor::Poll';
}
-use Test::More tests => 709;
+use Test::More tests => 703;
# "Wait you're the only friend I have...
# You really want a robot for a friend?
@@ -903,6 +903,10 @@ my $source = $t->tx->local_address;
$t->get_ok('/0', {'X-Forwarded-For' => '192.168.2.2, 192.168.2.1'})
->status_is(200)->content_like(qr#http\://localhost\:\d+/0\-$source\-0#);
+# GET /0 ("X-Forwarded-HTTPS")
+$t->get_ok('/0', {'X-Forwarded-HTTPS' => 1})->status_is(200)
+ ->content_like(qr#http\://localhost\:\d+/0\-$source\-0#);
+
# GET /0 (reverse proxy with "X-Forwarded-For")
{
local $ENV{MOJO_REVERSE_PROXY} = 1;
@@ -911,28 +915,11 @@ $t->get_ok('/0', {'X-Forwarded-For' => '192.168.2.2, 192.168.2.1'})
->content_like(qr#http\://localhost\:\d+/0\-192\.168\.2\.1\-0#);
}
-# GET /0 ("X-Forwarded-Host")
-$t->get_ok('/0', {'X-Forwarded-Host' => 'mojolicio.us:8080'})->status_is(200)
- ->content_like(qr#http\://localhost\:\d+/0\-$source\-0#);
-
-# GET /0 (reverse proxy with "X-Forwarded-Host")
-{
- local $ENV{MOJO_REVERSE_PROXY} = 1;
- $t->get_ok('/0', {'X-Forwarded-Host' => 'mojolicio.us:8080'})
- ->status_is(200)->content_is("http://mojolicio.us:8080/0-$source-0");
-}
-
-# GET /0 ("X-Forwarded-HTTPS" and "X-Forwarded-Host")
-$t->get_ok('/0',
- {'X-Forwarded-HTTPS' => 1, 'X-Forwarded-Host' => 'mojolicio.us'})
- ->status_is(200)->content_like(qr#http\://localhost\:\d+/0\-$source\-0#);
-
-# GET /0 (reverse proxy with "X-Forwarded-HTTPS" and "X-Forwarded-Host")
+# GET /0 (reverse proxy with "X-Forwarded-HTTPS")
{
local $ENV{MOJO_REVERSE_PROXY} = 1;
- $t->get_ok('/0',
- {'X-Forwarded-HTTPS' => 1, 'X-Forwarded-Host' => 'mojolicio.us'})
- ->status_is(200)->content_is("https://mojolicio.us/0-$source-0");
+ $t->get_ok('/0', {'X-Forwarded-HTTPS' => 1})->status_is(200)
+ ->content_like(qr#https\://localhost\:\d+/0\-$source\-0#);
}
# DELETE /inline/epl
Please sign in to comment.
Something went wrong with that request. Please try again.