Project

General

Profile

Feature #152

mod_proxy feature to remove part of the URI when passing along requests...

Added by Anonymous over 12 years ago. Updated 4 months ago.

Status:
Fixed
Priority:
Low
Assignee:
-
Category:
mod_proxy
Target version:
Start date:
Due date:
% Done:

100%

Estimated time:
Missing in 1.5.x:

Description

With mod_proxy, there's currently no way to let you map requests from http://somedomain.com/path/ to http://internalserver/. This is because the proxy will pass /path/ as the request URI to 'internalserver' instead of '/'.

mod_proxy needs to have an extra setting that either says "remove <extension> from the target URI", or "remove this from the target URI: '/somepath/'".

Associated revisions

Revision 036d3d3d (diff)
Added by gstrauss 5 months ago

[mod_proxy] simple host/url mapping in headers (fixes #152)

Provide a simple mechanism for mapping host and urlpath header strings
in proxied request and response well-known headers. This *is not*
intended as a one-size-fits-all, infinitely extensible, regex rewriting
engine. Instead, the proxy.header directive aims to provide built-in
functionality in mod_proxy for a few common use cases by performing
simple host matching or urlpath prefix matching, and using the
mapping of the first match. More complex use cases could possibly be
handled by a custom lighttpd module (which does not currently exist).

Note: the contents of the HTTP request-line and HTTP headers may or
may not be in normalized canonical forms, which may or may not influence
the simple matching performed. Admins should take care to provide safe
defaults (fail closed) if mapping is expected to occur and blindly
passing non-mapped requests is undesirable.

proxy.header = (
#"map-host-request" => (
#"-" => "...",#replace provided given Host request authority
#"..." => "-",#preserve existing authority (no further matching)
#"..." => "", #preserve existing authority (no further matching)
# #(equivalent to "xxx" => "xxx")
#"xxx" => "yyy", #map one string ("xxx") to another ("yyy")
#),
#"map-host-response" => (
#"-" => "...",#replace authority used in backend request
#"..." => "-",#replace with original authority
#"..." => "", #preserve existing authority (no further matching)
# #(equivalent to "xxx" => "xxx")
#"xxx" => "yyy", #map one string ("xxx") to another ("yyy")
#),
#"map-urlpath" => (
#"/xxx" => "/yyy",#map one urlpath prefix to another
#"/xxx/" => "/", #map one urlpath prefix to another
#"/xxx" => "", #map one urlpath prefix to another
#"/key" => "/value",
# Note: request headers have matching "key" prefix replaced with
# "value", and response headers have matching "value" prefix
# replaced with "key", with a pre-test of the "value" from the
# first-matched "key" in request headers (if there was a match)
#),
#"https-remap" => "enable",
# For https requests from client, map https:// to http://
# when map-host-request matches URI in request, and map http://
# to https:// when map-host-response matches URI in response.
# (mod_proxy currently sends all backend requests as http)
)

x-ref:
"feature to remove part of the URI when passing along requests..."
https://redmine.lighttpd.net/issues/152

History

#1 Updated by Anonymous over 12 years ago

I think this would be very useful too. It is like ProxyPass and ProxyPassReverse for apache.

-- miles.wu

#2 Updated by Anonymous almost 12 years ago

Add another vote for this.

-- cpisto

#3 Updated by Anonymous almost 12 years ago

Add another vote for this.

-- cpisto

#4 Updated by Anonymous over 11 years ago

+1

-- zimbatm

#5 Updated by Anonymous about 11 years ago

I could use this feature as well

I'm currently using mod_rewrite to 'fix' the URI before it is processed on the target system.

#6 Updated by gstrauss over 1 year ago

  • Description updated (diff)
  • Assignee deleted (jan)
  • Priority changed from High to Low

Much of what is requested here can be done by writing custom lua code and using mod_magnet. Another alternative is to use the scripting language of your choice to do the translation on the backend server that receives the proxied request.

However, to add this to lighttpd configuration settings is not a minor enhancement -- it would be a substantial amount of work. Supporting "Apache-style" ProxyPass and ProxyPassReverse would also require writing a user-interface to support various, complex, user-configurable settings, even if that user-interface was similar to Apache ProxyPass and ProxyPassReverse. When there were many fewer "programmers" than there are now, maybe learning how to program the "Apache-style" config language was more worthwhile than it is today. Today, I would suggest learning a scripting language is, at least in some cases, more worthwhile than learning the "Apache-style" config language.

#7 Updated by gstrauss 5 months ago

  • Status changed from New to Patch Pending
  • Target version set to 1.4.46

Experimental feature added with new directive proxy.header = ( ... )

Please see DevelGit and checkout branch personal/gstrauss/master to give it a try.

#8 Updated by gstrauss 4 months ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100

Also available in: Atom