Commit 0e96d0c0 authored by Andre Malo's avatar Andre Malo
Browse files

add support for rewrite rules in proxy containers

PR: 27985
Reviewed by: Jeff Trawick, Bill Stoddard


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@104840 13f79535-47bb-0310-9956-ffa450edef68
parent ef63cb37
Loading
Loading
Loading
Loading
+3 −0
Changes for CHANGES: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
Changes with Apache 2.0.51
  *) mod_rewrite now officially supports RewriteRules in <Proxy> sections.
     PR 27985.  [Andr Malo]
  *) mod_disk_cache: Implement binary format for on-disk header files.
     [Brian Akins <bakins web.turner.com>, Justin Erenkrantz]
+1 −5
Changes for STATUS: 1 added line, 5 removed lines.
Original line number Diff line number Diff line
APACHE 2.0 STATUS:                                              -*-text-*-
Last modified at [$Date: 2004/08/26 21:18:37 $]
Last modified at [$Date: 2004/08/26 21:53:23 $]

Release:

@@ -178,10 +178,6 @@ PATCHES TO BACKPORT FROM 2.1
         http://cvs.apache.org/viewcvs.cgi/httpd-2.0/modules/loggers/mod_log_config.c?r1=1.118&r2=1.119
       +1: trawick, nd, jerenkrantz

    *) (re-)add support for RewriteRules in <Proxy> containers. PR 27985
         modules/mappers/mod_rewrite.c: r1.254
       +1: nd, trawick, stoddard

    *) mod_include: remove "recursive-include" check, it's no longer
       necessary and forbids legal actions.
          modules/filters/mod_include.c: r1.296
+19 −2
Changes for modules/mappers/mod_rewrite.c: 19 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -1395,6 +1395,7 @@ static int hook_fixup(request_rec *r)
    int rulestatus;
    int n;
    char *ofilename;
    int is_proxyreq;

    dconf = (rewrite_perdir_conf *)ap_get_module_config(r->per_dir_config,
                                                        &rewrite_module);
@@ -1415,17 +1416,25 @@ static int hook_fixup(request_rec *r)
        return DECLINED;
    }

    /*
     * Proxy request?
     */
  	is_proxyreq = (   r->proxyreq && r->filename
  	               && !strncmp(r->filename, "proxy:", 6));

    /*
     *  .htaccess file is called before really entering the directory, i.e.:
     *  URL: http://localhost/foo  and .htaccess is located in foo directory
     *  Ignore such attempts, since they may lead to undefined behaviour.
     */
    if (is_proxyreq) {
        l = strlen(dconf->directory) - 1;
        if (r->filename && strlen(r->filename) == l &&
            (dconf->directory)[l] == '/' &&
            !strncmp(r->filename, dconf->directory, l)) {
            return DECLINED;
        }
    }

    /*
     *  only do something under runtime if the engine is really enabled,
@@ -1920,6 +1929,7 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
    rewritecond_entry *c;
    int i;
    int rc;
    int is_proxyreq = 0;

    /*
     *  Initialisation
@@ -1945,7 +1955,13 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
     *  threatment in the logfile.
     */
    if (perdir) {
        if (   strlen(uri) >= strlen(perdir)
        /*
  	     * Proxy request?
         */
  	    is_proxyreq = (   r->proxyreq && r->filename
  	                   && !strncmp(r->filename, "proxy:", 6));

        if (   !is_proxyreq && strlen(uri) >= strlen(perdir)
            && strncmp(uri, perdir, strlen(perdir)) == 0) {
            rewritelog(r, 3, "[per-dir %s] strip per-dir prefix: %s -> %s",
                       perdir, uri, uri+strlen(perdir));
@@ -2145,7 +2161,8 @@ static int apply_rewrite_rule(request_rec *r, rewriterule_entry *p,
     *   location, i.e. if it's not an absolute URL (!) path nor
     *   a fully qualified URL scheme.
     */
    if (perdir && *r->filename != '/' && !is_absolute_uri(r->filename)) {
    if (   perdir && !is_proxyreq && *r->filename != '/'
        && !is_absolute_uri(r->filename)) {
        rewritelog(r, 3, "[per-dir %s] add per-dir prefix: %s -> %s%s",
                   perdir, r->filename, perdir, r->filename);
        r->filename = apr_pstrcat(r->pool, perdir, r->filename, NULL);