Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse proxy path support for sub directory #484

Closed
yuki-kimoto opened this issue Apr 22, 2013 · 3 comments
Closed

Reverse proxy path support for sub directory #484

yuki-kimoto opened this issue Apr 22, 2013 · 3 comments

Comments

@yuki-kimoto
Copy link
Contributor

How about adding reverse proxy path support to core.

Reverse proxy is often used with proxy path.

http://somehost.com/app1
http://somehost.com/app2
http://somehost.com/foo/app1
http://somehost.com/foo/app2

The following implementation is an example to support proxy path.

# Reverse proxy support
my $reverse_proxy_on = $self->config->{hypnotoad}{proxy};
my $path_depth = $self->config->{hypnotoad}{proxy_path_depth};
if ($reverse_proxy_on) {
  $ENV{MOJO_REVERSE_PROXY} = 1;
  if ($path_depth) {
    $self->hook('before_dispatch' => sub {
      my $self = shift;
      for (1 .. $path_depth) {
        my $prefix = shift @{$self->req->url->path->parts};
        push @{$self->req->url->base->path->parts}, $prefix;
      }
    });
  }
}
@marcusramberg
Copy link
Member

Since there is no standard for this (afaik), and many possible setups (see my request base plugin for instance, I vote 👎 on adding this to core. 

Marcus

On Mon, Apr 22, 2013 at 11:08 AM, Yuki Kimoto notifications@github.com
wrote:

How about adding reverse proxy path support to core.
Reverse proxy is often used with proxy path.
http://somehost.com/app1
http://somehost.com/app2
http://somehost.com/foo/app1
http://somehost.com/foo/app2
The following implementation is an example to support proxy path.
# Reverse proxy support
my $reverse_proxy_on = $self->config->{hypnotoad}{proxy};
my $path_depth = $self->config->{hypnotoad}{proxy_path_depth};
if ($reverse_proxy_on) {
$ENV{MOJO_REVERSE_PROXY} = 1;
if ($path_depth) {
$self->hook('before_dispatch' => sub {
my $self = shift;
for (1 .. $path_depth) {
my $prefix = shift @{$self->req->url->path->parts};
push @{$self->req->url->base->path->parts}, $prefix;
}
});
}

}

Reply to this email directly or view it on GitHub:
#484

@kraih
Copy link
Member

kraih commented Apr 22, 2013

👎 from me as well for the same reason.

@kraih kraih closed this as completed Apr 22, 2013
@yuki-kimoto
Copy link
Contributor Author

OK. I maybe release it as plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants