Bug 52935 - ProxyPass SetEnvIf interpolation worked in 2.2
Summary: ProxyPass SetEnvIf interpolation worked in 2.2
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_proxy_http (show other bugs)
Version: 2.4.1
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk, PatchAvailable
: 52902 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-03-17 23:45 UTC by Petter Berntsen
Modified: 2012-05-06 07:25 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petter Berntsen 2012-03-17 23:45:22 UTC
Responds with '404 Not Found',

Works in 2.2.22, same config.

Works fine without env (ProxyPass / http;//duckduckgo.com/)


$ cat /usr/local/apache2/conf/extra/httpd-vhosts.conf
LogLevel proxy:trace8

<VirtualHost _default_:80>
#   SetEnv duck duckduckgo.com
    SetEnvIf Request_URI ".*" duck=duckduckgo.com
#   RewriteEngine On
#   RewriteRule ^ - [E=duck:duckduckgo.com]

    ProxyRequests Off 
    ProxyPassInterpolateEnv On
    ProxyPass / http://${duck}/ interpolate
#   ProxyPass / http://duckduckgo.com/
#   Header set duck "%{duck}e on 2.4.1"
</VirtualHost>


$ sudo /usr/local/apache2/bin/apachectl -k start; tail -fn0 /usr/local/apache2/logs/error_log 
[Sun Mar 18 00:39:33.582614 2012] [core:warn] [pid 14233:tid 140214237484864] AH00111: Config variable ${duck} is not defined
[Sun Mar 18 00:39:33.590089 2012] [proxy:debug] [pid 14236:tid 140214237484864] proxy_util.c(1640): AH00925: initializing worker proxy:reverse shared
[Sun Mar 18 00:39:33.590134 2012] [proxy:debug] [pid 14236:tid 140214237484864] proxy_util.c(1680): AH00927: initializing worker proxy:reverse local
[Sun Mar 18 00:39:33.590172 2012] [mpm_event:notice] [pid 14234:tid 140214237484864] AH00489: Apache/2.4.1 (Unix) configured -- resuming normal operations
[Sun Mar 18 00:39:33.590189 2012] [mpm_event:info] [pid 14234:tid 140214237484864] AH00490: Server built: Mar 15 2012 14:52:12
[Sun Mar 18 00:39:33.590195 2012] [proxy:debug] [pid 14236:tid 140214237484864] proxy_util.c(1712): AH00930: initialized pool in child 14236 for (*) min=0 max=25 smax=25
[Sun Mar 18 00:39:33.590206 2012] [proxy:debug] [pid 14236:tid 140214237484864] proxy_util.c(1640): AH00925: initializing worker http://${duck}/ shared
[Sun Mar 18 00:39:33.590220 2012] [proxy:debug] [pid 14236:tid 140214237484864] proxy_util.c(1680): AH00927: initializing worker http://${duck}/ local
[Sun Mar 18 00:39:33.590221 2012] [core:notice] [pid 14234:tid 140214237484864] AH00094: Command line: '/usr/local/apache2/bin/httpd'
[Sun Mar 18 00:39:33.590241 2012] [proxy:debug] [pid 14236:tid 140214237484864] proxy_util.c(1712): AH00930: initialized pool in child 14236 for (${duck}) min=0 max=25 smax=25
[Sun Mar 18 00:39:33.590236 2012] [proxy:debug] [pid 14237:tid 140214237484864] proxy_util.c(1640): AH00925: initializing worker proxy:reverse shared
[Sun Mar 18 00:39:33.590266 2012] [proxy:debug] [pid 14237:tid 140214237484864] proxy_util.c(1680): AH00927: initializing worker proxy:reverse local
[Sun Mar 18 00:39:33.590313 2012] [proxy:debug] [pid 14237:tid 140214237484864] proxy_util.c(1712): AH00930: initialized pool in child 14237 for (*) min=0 max=25 smax=25
[Sun Mar 18 00:39:33.590347 2012] [proxy:debug] [pid 14237:tid 140214237484864] proxy_util.c(1640): AH00925: initializing worker http://${duck}/ shared
[Sun Mar 18 00:39:33.590366 2012] [proxy:debug] [pid 14237:tid 140214237484864] proxy_util.c(1680): AH00927: initializing worker http://${duck}/ local
[Sun Mar 18 00:39:33.590379 2012] [proxy:debug] [pid 14237:tid 140214237484864] proxy_util.c(1712): AH00930: initialized pool in child 14237 for (${duck}) min=0 max=25 smax=25
[Sun Mar 18 00:39:33.590567 2012] [proxy:debug] [pid 14238:tid 140214237484864] proxy_util.c(1640): AH00925: initializing worker proxy:reverse shared
[Sun Mar 18 00:39:33.590596 2012] [proxy:debug] [pid 14238:tid 140214237484864] proxy_util.c(1680): AH00927: initializing worker proxy:reverse local
[Sun Mar 18 00:39:33.590640 2012] [proxy:debug] [pid 14238:tid 140214237484864] proxy_util.c(1712): AH00930: initialized pool in child 14238 for (*) min=0 max=25 smax=25
[Sun Mar 18 00:39:33.590651 2012] [proxy:debug] [pid 14238:tid 140214237484864] proxy_util.c(1640): AH00925: initializing worker http://${duck}/ shared
[Sun Mar 18 00:39:33.590663 2012] [proxy:debug] [pid 14238:tid 140214237484864] proxy_util.c(1680): AH00927: initializing worker http://${duck}/ local
[Sun Mar 18 00:39:33.590687 2012] [proxy:debug] [pid 14238:tid 140214237484864] proxy_util.c(1712): AH00930: initialized pool in child 14238 for (${duck}) min=0 max=25 smax=25
[Sun Mar 18 00:39:38.202264 2012] [core:info] [pid 14237:tid 140214135572224] [client ::1:60421] AH00128: File does not exist: proxy:http://duckduckgo.com/


$ /usr/local/apache2/bin/apachectl -V
Server version: Apache/2.4.1 (Unix)
Server built:   Mar 15 2012 14:52:12
Server's Module Magic Number: 20120211:0
Server loaded:  APR 1.4.5, APR-UTIL 1.4.1
Compiled using: APR 1.4.5, APR-UTIL 1.4.1
Architecture:   64-bit
Server MPM:     event
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"


$ cat config.nice 
#! /bin/sh
#
# Created by configure

"./configure" \
"$@"
Comment 1 Petter Berntsen 2012-03-19 13:19:55 UTC
Seem to have found a fix in mod_proxy.c child_init(). By adding the line:

conf->reverse = reverse;

to the end of the while loop. (As it is in httpd 2.2.22).


Otherwise it would fail to find a reverse proxy worker in proxy.util.c ap_proxy_pre_request(), because conf->reverse would be NULL.
And then proxy_handler() would return HTTP_SERVICE_UNAVAILABLE.
Comment 2 Ruediger Pluem 2012-03-19 13:48:38 UTC
*** Bug 52902 has been marked as a duplicate of this bug. ***
Comment 3 Ruediger Pluem 2012-03-19 13:55:51 UTC
(In reply to comment #1)
> Seem to have found a fix in mod_proxy.c child_init(). By adding the line:
> 
> conf->reverse = reverse;
> 
> to the end of the while loop. (As it is in httpd 2.2.22).
> 
> 
> Otherwise it would fail to find a reverse proxy worker in proxy.util.c
> ap_proxy_pre_request(), because conf->reverse would be NULL.
> And then proxy_handler() would return HTTP_SERVICE_UNAVAILABLE.

Thanks for the pointers. I committed a slightly modified version to trunk as r1302444.
Comment 4 Petter Berntsen 2012-03-19 14:25:16 UTC
I actually got recurring Segmentation fault's when i also removed the statement from within 'if (!reverse)'. So, i kept that one.


[core:notice] [pid 22626:tid 139771204532032] AH00052: child pid 25078 exit signal Segmentation fault (11)
Comment 5 Ruediger Pluem 2012-03-19 14:52:46 UTC
(In reply to comment #4)
> I actually got recurring Segmentation fault's when i also removed the statement
> from within 'if (!reverse)'. So, i kept that one.
> 
> 
> [core:notice] [pid 22626:tid 139771204532032] AH00052: child pid 25078 exit
> signal Segmentation fault (11)

Thanks for pointing this out. I was a little bit quick with my modification. Fixed in r1302483.
Comment 6 Petter Berntsen 2012-03-19 16:01:30 UTC
Sure thing :)


Just throwing in a couple unimportant code suggestions to avoid setting 'conf-reverse' twice the first round.

1. Delete 'conf->reverse = reverse;' from if block and send 'reverse' rather than 'conf->reverse' to ap_proxy_initialize_worker()

2. Put the second 'conf->reverse = reverse;' in an else block
Comment 7 Stefan Fritsch 2012-05-06 07:25:17 UTC
fixed in 2.4.2