accessing REMOTE_USER through an Apache proxy
accessing REMOTE_USER through an Apache proxy
am 28.10.2009 15:45:10 von Devin Bougie
--Apple-Mail-3--738963895
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=us-ascii;
format=flowed;
delsp=yes
We proxy connections trough Apache to GlassFish Web Applications, and
would like to give those applications access to the http REMOTE_USER
variable. To make sure this is not related to GlassFish, I have
created a very basic test script. The kerberos authentication and
Apache proxy work properly, and the script is able to see the
REMOTE_USER variable when called directly. However, the script can
not see the REMOTE_USER variable when it's accessed through a proxy.
It seems as though this has been discussed several times, but I have
not been able to make any of the proposed solutions work.
Here is the relevant portion of our configuration file file.
------
######
# GlassFish proxy
ProxyPreserveHost on
RewriteEngine on
RewriteLog /var/log/httpd/rewrite.log
RewriteLogLevel 9
RequestHeader Set Proxy-keysize 512
RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
RequestHeader Set Host ourserver.com:443
RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
RewriteRule ^/test$ /test/ [R,L]
RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1
[P,L,E=REMOTE_USER:%{LA-U:REMOTE_USER}]
order deny,allow
deny from all
AuthType KerberosV5
AuthName "kerberos authentication"
Satisfy any
require valid-user
------
And here is what I see in rewrite.log. REMOTE_USER is eventually set
properly, just not soon enough for the script.
------
.... [rid#8aa28f8/initial] (2) init rewrite engine with requested uri /
test/remote.cgi
.... [rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri '/test/
remote.cgi'
.... [rid#8aa28f8/initial] (3) applying pattern '^/test/(.*)' to uri '/
test/remote.cgi'
.... [rid#8aa28f8/initial] (2) rewrite /test/remote.cgi -> http://localhost/cgi-bin/test/remote.cgi
.... [rid#8aa4900/subreq] (2) init rewrite engine with requested uri /
test/remote.cgi
.... [rid#8aa4900/subreq] (1) pass through /test/remote.cgi
.... [rid#8aa28f8/initial] (5) lookahead: path=/test/remote.cgi
var=REMOTE_USER -> val=
.... [rid#8aa28f8/initial] (5) setting env variable 'REMOTE_USER' to ''
.... [rid#8aa28f8/initial] (2) forcing proxy-throughput with http://localhost/cgi-bin/test/remote.cgi
.... [rid#8aa28f8/initial] (1) go-ahead with proxy request proxy:http://
localhost/cgi-bin/test/remote.cgi [OK]
.... [rid#8aa8908/initial] (2) init rewrite engine with requested uri /
test/remote.cgi
.... [rid#8aa8908/initial] (3) applying pattern '^/test$' to uri '/test/
remote.cgi'
.... [rid#8aa8908/initial] (3) applying pattern '^/test/(.*)' to uri '/
test/remote.cgi'
.... [rid#8aa8908/initial] (2) rewrite /test/remote.cgi -> http://localhost/cgi-bin/test/remote.cgi
.... [rid#8abcf90/subreq] (2) init rewrite engine with requested uri /
test/remote.cgi
.... [rid#8abcf90/subreq] (1) pass through /test/remote.cgi
.... [rid#8aa8908/initial] (5) lookahead: path=/test/remote.cgi
var=REMOTE_USER -> val=dab66
.... [rid#8aa8908/initial] (5) setting env variable 'REMOTE_USER' to
'dab66'
.... [rid#8aa8908/initial] (2) forcing proxy-throughput with http://localhost/cgi-bin/test/remote.cgi
.... [rid#8aa8908/initial] (1) go-ahead with proxy request proxy:http://
localhost/cgi-bin/test/remote.cgi [OK]
------
Any suggestions would be greatly appreciated. Please let me know if
there is any more information I can provide.
Many thanks,
Devin
--Apple-Mail-3--738963895
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=us-ascii
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">We =
proxy connections trough Apache to GlassFish Web Applications, and would =
like to give those applications access to the http REMOTE_USER variable. =
To make sure this is not related to GlassFish, I have created a =
very basic test script. The kerberos authentication and Apache =
proxy work properly, and the script is able to see the REMOTE_USER =
variable when called directly. However, the script can not see the =
REMOTE_USER variable when it's accessed through a proxy. It =
seems as though this has been discussed several times, but I have not =
been able to make any of the proposed solutions =
work.
Here is the relevant portion of our =
configuration file file.
------
######
# GlassFish =
proxy
ProxyPreserveHost =
on
RewriteEngine =
on
RewriteL=
og /var/log/httpd/rewrite.log
RewriteLogLevel 9
RequestHeader =
Set Proxy-keysize 512
RequestHeader Set Proxy-ip =
%{REMOTE_ADDR}e
RequestHeader Set Host =
ourserver.com:443
RequestHeader set REMOTE_USER =
%{LA-U:REMOTE_USER}e
RewriteRule ^/test$ /test/ =
[R,L]
RewriteRule ^/test/(.*)
href=3D"http://localhost/cgi-bin/test/$1">http://localhost/c gi-bin/test/$1=
[P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
<Location =
"/test">
order =
deny,allow
deny from =
all
AuthType =
KerberosV5
AuthName =
"kerberos authentication"
Satisfy =
any
require =
valid-user
</Location>
------
And here is what I see =
in rewrite.log. REMOTE_USER is eventually set properly, just not =
soon enough for the script.
------
... [rid#8aa28f8/initial] (2) =
init rewrite engine with requested uri /test/remote.cgi
... =
[rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri =
'/test/remote.cgi'
... [rid#8aa28f8/initial] (3) applying pattern =
'^/test/(.*)' to uri '/test/remote.cgi'
... [rid#8aa28f8/initial] (2) =
rewrite /test/remote.cgi ->
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... [rid#8aa4900/subreq] (2) init rewrite engine =
with requested uri /test/remote.cgi
... [rid#8aa4900/subreq] (1) pass =
through /test/remote.cgi
... [rid#8aa28f8/initial] (5) lookahead: =
path=3D/test/remote.cgi var=3DREMOTE_USER -> val=3D
... =
[rid#8aa28f8/initial] (5) setting env variable 'REMOTE_USER' to =
''
... [rid#8aa28f8/initial] (2) forcing proxy-throughput =
with
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... [rid#8aa28f8/initial] (1) go-ahead with =
proxy request proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
... =
[rid#8aa8908/initial] (2) init rewrite engine with requested uri =
/test/remote.cgi
... [rid#8aa8908/initial] (3) applying pattern =
'^/test$' to uri '/test/remote.cgi'
... [rid#8aa8908/initial] (3) =
applying pattern '^/test/(.*)' to uri '/test/remote.cgi'
... =
[rid#8aa8908/initial] (2) rewrite /test/remote.cgi ->
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... [rid#8abcf90/subreq] (2) init rewrite engine =
with requested uri /test/remote.cgi
... [rid#8abcf90/subreq] (1) pass =
through /test/remote.cgi
... [rid#8aa8908/initial] (5) lookahead: =
path=3D/test/remote.cgi var=3DREMOTE_USER -> val=3Ddab66
... =
[rid#8aa8908/initial] (5) setting env variable 'REMOTE_USER' to =
'dab66'
... [rid#8aa8908/initial] (2) forcing proxy-throughput =
with
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... [rid#8aa8908/initial] (1) go-ahead with =
proxy request proxy:http://localhost/cgi-bin/test/remote.cgi =
[OK]
------
Any suggestions would be greatly appreciated. =
Please let me know if there is any more information I can =
provide.
Many =
thanks,
Devin
=
--Apple-Mail-3--738963895--
Re: accessing REMOTE_USER through an Apache proxy
am 28.10.2009 16:15:02 von aw
Devin Bougie wrote:
....
Hi.
I'll give you my interpretation, after looking at the log, not really at
the configuration.
I think the confusion may be about when and where, things happen
exactly. And it is not really helped by your choice to proxy from your
server to itself..
If you examine the log below, you will see different/distinct requests,
identified by their respective "rid" number.
The first is the request rid#8aa28f8 that comes in originally, on your
"first" server (before the proxying occurs).
That one does the proxying before your is even invoked
(in my opinion). So at that point, the authentication has not even
happened, and REMOTE_USER is undefined or empty.
That request, you then proxy to your "second" server.
Now the proxied request comes in to your "second" server. That is
request rid#8aa8908. That one starts without a REMOTE_USER (see above),
but then goes through the section, where it acquires an id.
But by then it is too late for proxying..
It would all probably be clearer if you set this up in two distinct
VirtualHosts, and proxied from the first to the second.
Another thing, is that Apache "environment variables", are kind of
"virtual", in the sense that they exist inside of Apache, for the
duration of one request.
When you proxy something to another server, this is a new request, and
this other server does not magically inherit the environment of your
first request in the first server.
To pass it on, you would have to set it in a header which you pass to
the second server. But then, you must have a value to pass, by the time
you create the header.
Which does not seem to be the case here.
Hope that is clear.
As for me, I think I need a cup of coffee now.
>
> ------
> ######
> # GlassFish proxy
> ProxyPreserveHost on
>
> RewriteEngine on
> RewriteLog /var/log/httpd/rewrite.log
> RewriteLogLevel 9
>
> RequestHeader Set Proxy-keysize 512
> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
> RequestHeader Set Host ourserver.com:443
> RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
>
> RewriteRule ^/test$ /test/ [R,L]
> RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1
> [P,L,E=REMOTE_USER:%{LA-U:REMOTE_USER}]
>
> order deny,allow
> deny from all
> AuthType KerberosV5
> AuthName "kerberos authentication"
> Satisfy any
> require valid-user
>
> ------
>
> And here is what I see in rewrite.log. REMOTE_USER is eventually set
> properly, just not soon enough for the script.
> ------
> ... [rid#8aa28f8/initial] (2) init rewrite engine with requested uri
> /test/remote.cgi
> ... [rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri
> '/test/remote.cgi'
> ... [rid#8aa28f8/initial] (3) applying pattern '^/test/(.*)' to uri
> '/test/remote.cgi'
> ... [rid#8aa28f8/initial] (2) rewrite /test/remote.cgi ->
> http://localhost/cgi-bin/test/remote.cgi
> ... [rid#8aa4900/subreq] (2) init rewrite engine with requested uri
> /test/remote.cgi
> ... [rid#8aa4900/subreq] (1) pass through /test/remote.cgi
> ... [rid#8aa28f8/initial] (5) lookahead: path=/test/remote.cgi
> var=REMOTE_USER -> val=
> ... [rid#8aa28f8/initial] (5) setting env variable 'REMOTE_USER' to ''
> ... [rid#8aa28f8/initial] (2) forcing proxy-throughput with
> http://localhost/cgi-bin/test/remote.cgi
> ... [rid#8aa28f8/initial] (1) go-ahead with proxy request
> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
> ... [rid#8aa8908/initial] (2) init rewrite engine with requested uri
> /test/remote.cgi
> ... [rid#8aa8908/initial] (3) applying pattern '^/test$' to uri
> '/test/remote.cgi'
> ... [rid#8aa8908/initial] (3) applying pattern '^/test/(.*)' to uri
> '/test/remote.cgi'
> ... [rid#8aa8908/initial] (2) rewrite /test/remote.cgi ->
> http://localhost/cgi-bin/test/remote.cgi
> ... [rid#8abcf90/subreq] (2) init rewrite engine with requested uri
> /test/remote.cgi
> ... [rid#8abcf90/subreq] (1) pass through /test/remote.cgi
> ... [rid#8aa8908/initial] (5) lookahead: path=/test/remote.cgi
> var=REMOTE_USER -> val=dab66
> ... [rid#8aa8908/initial] (5) setting env variable 'REMOTE_USER' to 'dab66'
> ... [rid#8aa8908/initial] (2) forcing proxy-throughput with
> http://localhost/cgi-bin/test/remote.cgi
> ... [rid#8aa8908/initial] (1) go-ahead with proxy request
> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
> ------
>
> Any suggestions would be greatly appreciated. Please let me know if
> there is any more information I can provide.
>
> Many thanks,
> Devin
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: accessing REMOTE_USER through an Apache proxy
am 28.10.2009 21:03:47 von Devin Bougie
--Apple-Mail-5--719847092
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=iso-8859-1;
format=flowed;
delsp=yes
Hi Andr=E9,
Thank you very much for your time and explanation. For what it's =20
worth, I have tried inserting a RewriteCond to make sure the proxy =20
only occurs when REMOTE_USER is set. This cleaned up the rewrite.log =20=
file a bit, but the script is still not able to see REMOTE_USER. Here =20=
is our updated configuration and rewrite.log.
------
######
# GlassFish proxy
ProxyPreserveHost on
RewriteEngine on
RewriteCond %{LA-U:REMOTE_USER} (.+)
RewriteLog /var/log/httpd/rewrite.log
RewriteLogLevel 9
RequestHeader Set Proxy-keysize 512
RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
RequestHeader Set Host ourserver.com:443
RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
RewriteRule ^/test$ /test/ [R,L]
RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1 =20
[P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
order deny,allow
deny from all
AuthType KerberosV5
AuthName "kerberos authentication"
Satisfy any
require valid-user
------
.... [rid#8e23fc0/initial] (2) init rewrite engine with requested uri /=20=
test/remote.cgi
.... [rid#8e23fc0/initial] (3) applying pattern '^/test$' to uri '/test/=20=
remote.cgi'
.... [rid#8e23fc0/initial] (3) applying pattern '^/test/(.*)' to uri '/=20=
test/remote.cgi'
.... [rid#8e23fc0/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
.... [rid#8e38648/subreq] (2) init rewrite engine with requested uri /=20
test/remote.cgi
.... [rid#8e38648/subreq] (1) pass through /test/remote.cgi
.... [rid#8e23fc0/initial] (5) lookahead: path=3D/test/remote.cgi =20
var=3DREMOTE_USER -> val=3Ddab66
.... [rid#8e23fc0/initial] (5) setting env variable 'REMOTE_USER' to =20
'dab66'
.... [rid#8e23fc0/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
.... [rid#8e23fc0/initial] (1) go-ahead with proxy request proxy:http://=20=
localhost/cgi-bin/test/remote.cgi [OK]
------
Our end goal is to proxy from the Apache server to a GlassFish =20
Enterprise Server. Just for reference, here is the rewrite.log for a =20=
request that's proxied to a GlassFish Web Application.
------
.... [rid#8e23fc8/initial] (2) init rewrite engine with requested uri /=20=
HelloWeb/UserServlet
.... [rid#8e23fc8/initial] (3) applying pattern '^/HelloWeb$' to uri '/=20=
HelloWeb/UserServlet'
.... [rid#8e23fc8/initial] (3) applying pattern '^/HelloWeb/(.*)' to =20
uri '/HelloWeb/UserServlet'
.... [rid#8e23fc8/initial] (2) rewrite /HelloWeb/UserServlet -> =
http://localhost:38080/HelloWeb/UserServlet
.... [rid#8e1ffb8/subreq] (2) init rewrite engine with requested uri /=20
HelloWeb/UserServlet
.... [rid#8e1ffb8/subreq] (1) pass through /HelloWeb/UserServlet
.... [rid#8e23fc8/initial] (5) lookahead: path=3D/HelloWeb/UserServlet =20=
var=3DREMOTE_USER -> val=3Ddab66
.... [rid#8e23fc8/initial] (5) setting env variable 'REMOTE_USER' to =20
'dab66'
.... [rid#8e23fc8/initial] (2) forcing proxy-throughput with =
http://localhost:38080/HelloWeb/UserServlet
.... [rid#8e23fc8/initial] (1) go-ahead with proxy request proxy:http://=20=
localhost:38080/HelloWeb/UserServlet [OK]
------
Any suggestions would be greatly appreciated.
Thank you again,
Devin
On Oct 28, 2009, at 11:15 AM, Andr=E9 Warnier wrote:
> Devin Bougie wrote:
> ...
>
> Hi.
>
> I'll give you my interpretation, after looking at the log, not =20
> really at the configuration.
>
> I think the confusion may be about when and where, things happen =20
> exactly. And it is not really helped by your choice to proxy from =20
> your server to itself..
>
> If you examine the log below, you will see different/distinct =20
> requests, identified by their respective "rid" number.
>
> The first is the request rid#8aa28f8 that comes in originally, on =20
> your "first" server (before the proxying occurs).
> That one does the proxying before your is even =20
> invoked (in my opinion). So at that point, the authentication has =20
> not even happened, and REMOTE_USER is undefined or empty.
> That request, you then proxy to your "second" server.
>
> Now the proxied request comes in to your "second" server. That is =20
> request rid#8aa8908. That one starts without a REMOTE_USER (see =20
> above), but then goes through the section, where it =20
> acquires an id.
> But by then it is too late for proxying..
>
> It would all probably be clearer if you set this up in two distinct =20=
> VirtualHosts, and proxied from the first to the second.
>
> Another thing, is that Apache "environment variables", are kind of =20
> "virtual", in the sense that they exist inside of Apache, for the =20
> duration of one request.
> When you proxy something to another server, this is a new request, =20
> and this other server does not magically inherit the environment of =20=
> your first request in the first server.
> To pass it on, you would have to set it in a header which you pass =20
> to the second server. But then, you must have a value to pass, by =20
> the time you create the header.
> Which does not seem to be the case here.
>
> Hope that is clear.
> As for me, I think I need a cup of coffee now.
>
>
>> ------
>> ######
>> # GlassFish proxy
>> ProxyPreserveHost on
>> RewriteEngine on
>> RewriteLog /var/log/httpd/rewrite.log
>> RewriteLogLevel 9
>> RequestHeader Set Proxy-keysize 512
>> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
>> RequestHeader Set Host ourserver.com:443
>> RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
>> RewriteRule ^/test$ /test/ [R,L]
>> RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1 =20
>> [P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
>>
>> order deny,allow
>> deny from all
>> AuthType KerberosV5
>> AuthName "kerberos authentication"
>> Satisfy any
>> require valid-user
>>
>> ------
>> And here is what I see in rewrite.log. REMOTE_USER is eventually =20
>> set properly, just not soon enough for the script.
>> ------
>> ... [rid#8aa28f8/initial] (2) init rewrite engine with requested =20
>> uri /test/remote.cgi
>> ... [rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri '/=20
>> test/remote.cgi'
>> ... [rid#8aa28f8/initial] (3) applying pattern '^/test/(.*)' to uri =20=
>> '/test/remote.cgi'
>> ... [rid#8aa28f8/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
>> ... [rid#8aa4900/subreq] (2) init rewrite engine with requested =20
>> uri /test/remote.cgi
>> ... [rid#8aa4900/subreq] (1) pass through /test/remote.cgi
>> ... [rid#8aa28f8/initial] (5) lookahead: path=3D/test/remote.cgi =20
>> var=3DREMOTE_USER -> val=3D
>> ... [rid#8aa28f8/initial] (5) setting env variable 'REMOTE_USER' to =20=
>> ''
>> ... [rid#8aa28f8/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
>> ... [rid#8aa28f8/initial] (1) go-ahead with proxy request =20
>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>> ... [rid#8aa8908/initial] (2) init rewrite engine with requested =20
>> uri /test/remote.cgi
>> ... [rid#8aa8908/initial] (3) applying pattern '^/test$' to uri '/=20
>> test/remote.cgi'
>> ... [rid#8aa8908/initial] (3) applying pattern '^/test/(.*)' to uri =20=
>> '/test/remote.cgi'
>> ... [rid#8aa8908/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
>> ... [rid#8abcf90/subreq] (2) init rewrite engine with requested =20
>> uri /test/remote.cgi
>> ... [rid#8abcf90/subreq] (1) pass through /test/remote.cgi
>> ... [rid#8aa8908/initial] (5) lookahead: path=3D/test/remote.cgi =20
>> var=3DREMOTE_USER -> val=3Ddab66
>> ... [rid#8aa8908/initial] (5) setting env variable 'REMOTE_USER' to =20=
>> 'dab66'
>> ... [rid#8aa8908/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
>> ... [rid#8aa8908/initial] (1) go-ahead with proxy request =20
>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>> ------
>> Any suggestions would be greatly appreciated. Please let me know =20
>> if there is any more information I can provide.
>> Many thanks,
>> Devin
>
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server =20
> Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
--Apple-Mail-5--719847092
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=iso-8859-1
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">Hi Andr=E9,
Thank you very much for your time =
and explanation. For what it's worth, I have tried inserting a =
RewriteCond to make sure the proxy only occurs when REMOTE_USER is set. =
This cleaned up the rewrite.log file a bit, but the script is =
still not able to see REMOTE_USER. Here is our updated =
configuration and =
rewrite.log.
------
######
# =
GlassFish proxy
ProxyPreserveHost =
on
RewriteEngine =
onRe=
writeCond %{LA-U:REMOTE_USER} (.+)
RewriteLog =
/var/log/httpd/rewrite.log
RewriteLogLevel 9
RequestHeader Set =
Proxy-keysize 512
RequestHeader Set Proxy-ip =
%{REMOTE_ADDR}e
RequestHeader Set Host =
ourserver.com:443
RequestHeader set REMOTE_USER =
%{LA-U:REMOTE_USER}e
RewriteRule ^/test$ /test/ =
[R,L]
RewriteRule ^/test/(.*)
href=3D"http://localhost/cgi-bin/test/$1">http://localhost/c gi-bin/test/$1=
[P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
<Location =
"/test">
order =
deny,allow
deny from =
all
AuthType =
KerberosV5
AuthName =
"kerberos authentication"
Satisfy =
any
require =
valid-user
</Location>
------
... =
[rid#8e23fc0/initial] (2) init rewrite engine with requested uri =
/test/remote.cgi
... [rid#8e23fc0/initial] (3) applying =
pattern '^/test$' to uri =
'/test/remote.cgi'
... [rid#8e23fc0/initial] (3) applying =
pattern '^/test/(.*)' to uri =
'/test/remote.cgi'
... [rid#8e23fc0/initial] (2) rewrite =
/test/remote.cgi ->
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... [rid#8e38648/subreq] (2) init =
rewrite engine with requested uri =
/test/remote.cgi
... [rid#8e38648/subreq] (1) pass =
through /test/remote.cgi
... [rid#8e23fc0/initial] (5) =
lookahead: path=3D/test/remote.cgi var=3DREMOTE_USER -> =
val=3Ddab66
... [rid#8e23fc0/initial] (5) setting env =
variable 'REMOTE_USER' to =
'dab66'
... [rid#8e23fc0/initial] (2) forcing =
proxy-throughput with
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... [rid#8e23fc0/initial] (1) =
go-ahead with proxy request =
proxy:http://localhost/cgi-bin/test/remote.cgi =
[OK]
------
Our end goal is to =
proxy from the Apache server to a GlassFish Enterprise Server. =
Just for reference, here is the rewrite.log for a request that's =
proxied to a GlassFish Web =
Application.
------
... [rid#8e23fc8/initial=
] (2) init rewrite engine with requested uri =
/HelloWeb/UserServlet
... [rid#8e23fc8/initial] (3) =
applying pattern '^/HelloWeb$' to uri =
'/HelloWeb/UserServlet'
... [rid#8e23fc8/initial] (3) =
applying pattern '^/HelloWeb/(.*)' to uri =
'/HelloWeb/UserServlet'
... [rid#8e23fc8/initial] (2) =
rewrite /HelloWeb/UserServlet ->
href=3D"http://localhost:38080/HelloWeb/UserServlet">http:// localhost:3808=
0/HelloWeb/UserServlet
... [rid#8e1ffb8/subreq] (2) =
init rewrite engine with requested uri =
/HelloWeb/UserServlet
... [rid#8e1ffb8/subreq] (1) pass =
through /HelloWeb/UserServlet
... [rid#8e23fc8/initial] =
(5) lookahead: path=3D/HelloWeb/UserServlet var=3DREMOTE_USER -> =
val=3Ddab66
... [rid#8e23fc8/initial] (5) setting env =
variable 'REMOTE_USER' to =
'dab66'
... [rid#8e23fc8/initial] (2) forcing =
proxy-throughput with
href=3D"http://localhost:38080/HelloWeb/UserServlet">http:// localhost:3808=
0/HelloWeb/UserServlet
... [rid#8e23fc8/initial] (1) =
go-ahead with proxy request =
proxy:http://localhost:38080/HelloWeb/UserServlet =
[OK]
------
Any suggestions =
would be greatly appreciated.
Thank you =
again,
Devin
On Oct 28, 2009, at 11:15 =
AM, Andr=E9 Warnier wrote:
class=3D"Apple-interchange-newline">
Devin =
Bougie wrote:
...
Hi.
I'll give you my interpretation, =
after looking at the log, not really at the configuration.
I =
think the confusion may be about when and where, things happen exactly. =
And it is not really helped by your choice to proxy from your server to =
itself..
If you examine the log below, you will see =
different/distinct requests, identified by their respective "rid" =
number.
The first is the request rid#8aa28f8 that comes in =
originally, on your "first" server (before the proxying occurs).
That =
one does the proxying before your <Location /test> is even invoked =
(in my opinion). So at that point, the authentication has not even =
happened, and REMOTE_USER is undefined or empty.
That request, you =
then proxy to your "second" server.
Now the proxied request comes =
in to your "second" server. That is request rid#8aa8908. That one =
starts without a REMOTE_USER (see above), but then goes through the =
<Location> section, where it acquires an id.
But by then it is =
too late for proxying..
It would all probably be clearer if you =
set this up in two distinct VirtualHosts, and proxied from the first to =
the second.
Another thing, is that Apache "environment =
variables", are kind of "virtual", in the sense that they exist inside =
of Apache, for the duration of one request.
When you proxy something =
to another server, this is a new request, and this other server does not =
magically inherit the environment of your first request in the first =
server.
To pass it on, you would have to set it in a header which you =
pass to the second server. But then, you must have a value to =
pass, by the time you create the header.
Which does not seem to be =
the case here.
Hope that is clear.
As for me, I think I need a =
cup of coffee now.
type=3D"cite">------
type=3D"cite">######
# =
GlassFish proxy
type=3D"cite">ProxyPreserveHost =
on
type=3D"cite">RewriteEngine =
on
uote>
RewriteLog =
/var/log/httpd/rewrite.log
type=3D"cite">RewriteLogLevel 9
type=3D"cite">RequestHeader Set Proxy-keysize =
512
RequestHeader Set Proxy-ip =
%{REMOTE_ADDR}e
RequestHeader =
Set Host ourserver.com:443
type=3D"cite">RequestHeader set REMOTE_USER =
%{LA-U:REMOTE_USER}e
RewriteRule=
^/test$ /test/ [R,L]
type=3D"cite">RewriteRule ^/test/(.*)
href=3D"http://localhost/cgi-bin/test/$1">http://localhost/c gi-bin/test/$1=
[P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
type=3D"cite"><Location "/test">
type=3D"cite"> order =
deny,allow
=
deny from =
all
=
AuthType =
KerberosV5
=
AuthName "kerberos =
authentication"
=
Satisfy =
any
=
require =
valid-user
type=3D"cite"></Location>
type=3D"cite">------
And here =
is what I see in rewrite.log. REMOTE_USER is eventually set =
properly, just not soon enough for the =
script.
type=3D"cite">------
... =
[rid#8aa28f8/initial] (2) init rewrite engine with requested uri =
/test/remote.cgi
... =
[rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri =
'/test/remote.cgi'
... =
[rid#8aa28f8/initial] (3) applying pattern '^/test/(.*)' to uri =
'/test/remote.cgi'
... =
[rid#8aa28f8/initial] (2) rewrite /test/remote.cgi ->
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... =
[rid#8aa4900/subreq] (2) init rewrite engine with requested uri =
/test/remote.cgi
... =
[rid#8aa4900/subreq] (1) pass through =
/test/remote.cgi
... =
[rid#8aa28f8/initial] (5) lookahead: path=3D/test/remote.cgi =
var=3DREMOTE_USER -> val=3D
type=3D"cite">... [rid#8aa28f8/initial] (5) setting env variable =
'REMOTE_USER' to ''
... =
[rid#8aa28f8/initial] (2) forcing proxy-throughput with
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... =
[rid#8aa28f8/initial] (1) go-ahead with proxy request =
proxy:http://localhost/cgi-bin/test/remote.cgi =
[OK]
... [rid#8aa8908/initial] =
(2) init rewrite engine with requested uri =
/test/remote.cgi
... =
[rid#8aa8908/initial] (3) applying pattern '^/test$' to uri =
'/test/remote.cgi'
... =
[rid#8aa8908/initial] (3) applying pattern '^/test/(.*)' to uri =
'/test/remote.cgi'
... =
[rid#8aa8908/initial] (2) rewrite /test/remote.cgi ->
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... =
[rid#8abcf90/subreq] (2) init rewrite engine with requested uri =
/test/remote.cgi
... =
[rid#8abcf90/subreq] (1) pass through =
/test/remote.cgi
... =
[rid#8aa8908/initial] (5) lookahead: path=3D/test/remote.cgi =
var=3DREMOTE_USER -> val=3Ddab66
type=3D"cite">... [rid#8aa8908/initial] (5) setting env variable =
'REMOTE_USER' to 'dab66'
... =
[rid#8aa8908/initial] (2) forcing proxy-throughput with
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... =
[rid#8aa8908/initial] (1) go-ahead with proxy request =
proxy:http://localhost/cgi-bin/test/remote.cgi =
[OK]
type=3D"cite">------
Any =
suggestions would be greatly appreciated. Please let me know if =
there is any more information I can provide.
type=3D"cite">Many thanks,
type=3D"cite">Devin
------------------------------=
---------------------------------------
The official User-To-User =
support forum of the Apache HTTP Server Project.
See =
<URL:http://httpd.apache.org/userslist.html> for more info.
To =
unsubscribe, e-mail:
href=3D"mailto:users-unsubscribe@httpd.apache.org">users-uns ubscribe@httpd=
..apache.org
" from the digest:
href=3D"mailto:users-digest-unsubscribe@httpd.apache.org">us ers-digest-uns=
ubscribe@httpd.apache.org
For additional commands, e-mail:
href=3D"mailto:users-help@httpd.apache.org">users-help@httpd .apache.org
>
=
--Apple-Mail-5--719847092--
Re: accessing REMOTE_USER through an Apache proxy
am 29.10.2009 23:21:19 von Devin Bougie
--Apple-Mail-10--625194498
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=iso-8859-1;
format=flowed;
delsp=yes
I have tried a different approach by moving the RewriteRules into the =20=
Location directive. With this configuration, the HTTP_REMOTE_USER =20
variable is set and visible by the backend script and application. =20
However, REMOTE_USER is still blank. Here is the alternate =20
configuration:
------
order deny,allow
deny from all
AuthType KerberosV5
AuthName "W4restrict"
KrbDefaultInstance net
Satisfy any
require valid-user
RewriteEngine on
RewriteCond %{REMOTE_USER} (.+)
RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
RequestHeader Set Host ourserver.com:443
RequestHeader set REMOTE_USER %{REMOTE_USER}e
RewriteRule ^/var/www/html/test/(.*) =
http://localhost/cgi-bin/test/$1=20
[P,L,E=3DREMOTE_USER:%{REMOTE_USER}]
------
And here is what we see in rewrite.log:
------
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
] (3) [per-dir /test/] add path info postfix: /var/www/html/test -> /=20
var/www/html/test/remote.cgi
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
] (3) [per-dir /test/] applying pattern '^/var/www/html/test/(.*)' to =20=
uri '/var/www/html/test/remote.cgi'
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
] (4) RewriteCond: input=3D'dab66' pattern=3D'(.+)' =3D> matched
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
] (2) [per-dir /test/] rewrite /var/www/html/test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
] (5) setting env variable 'REMOTE_USER' to 'dab66'
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
] (2) [per-dir /test/] forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
] (1) [per-dir /test/] go-ahead with proxy request proxy:http://=20
localhost/cgi-bin/test/remote.cgi [OK]
------
Any suggestions for passing REMOTE_USER through an Apache proxy would =20=
be greatly appreciated.
Many Thanks,
Devin
On Oct 28, 2009, at 4:03 PM, Devin Bougie wrote:
> ... For what it's worth, I have tried inserting a RewriteCond to =20
> make sure the proxy only occurs when REMOTE_USER is set. This =20
> cleaned up the rewrite.log file a bit, but the script is still not =20
> able to see REMOTE_USER. Here is our updated configuration and =20
> rewrite.log.
>
> ------
> ######
> # GlassFish proxy
> ProxyPreserveHost on
>
> RewriteEngine on
> RewriteCond %{LA-U:REMOTE_USER} (.+)
> RewriteLog /var/log/httpd/rewrite.log
> RewriteLogLevel 9
>
> RequestHeader Set Proxy-keysize 512
> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
> RequestHeader Set Host ourserver.com:443
> RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
>
> RewriteRule ^/test$ /test/ [R,L]
> RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1 =20
> [P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
>
> order deny,allow
> deny from all
> AuthType KerberosV5
> AuthName "kerberos authentication"
> Satisfy any
> require valid-user
>
> ------
> ... [rid#8e23fc0/initial] (2) init rewrite engine with requested =20
> uri /test/remote.cgi
> ... [rid#8e23fc0/initial] (3) applying pattern '^/test$' to uri '/=20
> test/remote.cgi'
> ... [rid#8e23fc0/initial] (3) applying pattern '^/test/(.*)' to uri =20=
> '/test/remote.cgi'
> ... [rid#8e23fc0/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
> ... [rid#8e38648/subreq] (2) init rewrite engine with requested uri /=20=
> test/remote.cgi
> ... [rid#8e38648/subreq] (1) pass through /test/remote.cgi
> ... [rid#8e23fc0/initial] (5) lookahead: path=3D/test/remote.cgi =20
> var=3DREMOTE_USER -> val=3Ddab66
> ... [rid#8e23fc0/initial] (5) setting env variable 'REMOTE_USER' to =20=
> 'dab66'
> ... [rid#8e23fc0/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
> ... [rid#8e23fc0/initial] (1) go-ahead with proxy request =20
> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
> ------
>
> Our end goal is to proxy from the Apache server to a GlassFish =20
> Enterprise Server. Just for reference, here is the rewrite.log for =20=
> a request that's proxied to a GlassFish Web Application.
> ------
> ... [rid#8e23fc8/initial] (2) init rewrite engine with requested =20
> uri /HelloWeb/UserServlet
> ... [rid#8e23fc8/initial] (3) applying pattern '^/HelloWeb$' to uri =20=
> '/HelloWeb/UserServlet'
> ... [rid#8e23fc8/initial] (3) applying pattern '^/HelloWeb/(.*)' to =20=
> uri '/HelloWeb/UserServlet'
> ... [rid#8e23fc8/initial] (2) rewrite /HelloWeb/UserServlet -> =
http://localhost:38080/HelloWeb/UserServlet
> ... [rid#8e1ffb8/subreq] (2) init rewrite engine with requested uri /=20=
> HelloWeb/UserServlet
> ... [rid#8e1ffb8/subreq] (1) pass through /HelloWeb/UserServlet
> ... [rid#8e23fc8/initial] (5) lookahead: path=3D/HelloWeb/UserServlet =20=
> var=3DREMOTE_USER -> val=3Ddab66
> ... [rid#8e23fc8/initial] (5) setting env variable 'REMOTE_USER' to =20=
> 'dab66'
> ... [rid#8e23fc8/initial] (2) forcing proxy-throughput with =
http://localhost:38080/HelloWeb/UserServlet
> ... [rid#8e23fc8/initial] (1) go-ahead with proxy request =20
> proxy:http://localhost:38080/HelloWeb/UserServlet [OK]
> ------
>
> Any suggestions would be greatly appreciated.
>
> Thank you again,
> Devin
>
> On Oct 28, 2009, at 11:15 AM, Andr=E9 Warnier wrote:
>
>> Devin Bougie wrote:
>> ...
>>
>> Hi.
>>
>> I'll give you my interpretation, after looking at the log, not =20
>> really at the configuration.
>>
>> I think the confusion may be about when and where, things happen =20
>> exactly. And it is not really helped by your choice to proxy from =20
>> your server to itself..
>>
>> If you examine the log below, you will see different/distinct =20
>> requests, identified by their respective "rid" number.
>>
>> The first is the request rid#8aa28f8 that comes in originally, on =20
>> your "first" server (before the proxying occurs).
>> That one does the proxying before your is even =20
>> invoked (in my opinion). So at that point, the authentication has =20=
>> not even happened, and REMOTE_USER is undefined or empty.
>> That request, you then proxy to your "second" server.
>>
>> Now the proxied request comes in to your "second" server. That is =20
>> request rid#8aa8908. That one starts without a REMOTE_USER (see =20
>> above), but then goes through the section, where it =20
>> acquires an id.
>> But by then it is too late for proxying..
>>
>> It would all probably be clearer if you set this up in two distinct =20=
>> VirtualHosts, and proxied from the first to the second.
>>
>> Another thing, is that Apache "environment variables", are kind of =20=
>> "virtual", in the sense that they exist inside of Apache, for the =20
>> duration of one request.
>> When you proxy something to another server, this is a new request, =20=
>> and this other server does not magically inherit the environment of =20=
>> your first request in the first server.
>> To pass it on, you would have to set it in a header which you pass =20=
>> to the second server. But then, you must have a value to pass, by =20=
>> the time you create the header.
>> Which does not seem to be the case here.
>>
>> Hope that is clear.
>> As for me, I think I need a cup of coffee now.
>>
>>
>>> ------
>>> ######
>>> # GlassFish proxy
>>> ProxyPreserveHost on
>>> RewriteEngine on
>>> RewriteLog /var/log/httpd/rewrite.log
>>> RewriteLogLevel 9
>>> RequestHeader Set Proxy-keysize 512
>>> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
>>> RequestHeader Set Host ourserver.com:443
>>> RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
>>> RewriteRule ^/test$ /test/ [R,L]
>>> RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1 =20
>>> [P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
>>>
>>> order deny,allow
>>> deny from all
>>> AuthType KerberosV5
>>> AuthName "kerberos authentication"
>>> Satisfy any
>>> require valid-user
>>>
>>> ------
>>> And here is what I see in rewrite.log. REMOTE_USER is eventually =20=
>>> set properly, just not soon enough for the script.
>>> ------
>>> ... [rid#8aa28f8/initial] (2) init rewrite engine with requested =20
>>> uri /test/remote.cgi
>>> ... [rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri '/=20=
>>> test/remote.cgi'
>>> ... [rid#8aa28f8/initial] (3) applying pattern '^/test/(.*)' to =20
>>> uri '/test/remote.cgi'
>>> ... [rid#8aa28f8/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
>>> ... [rid#8aa4900/subreq] (2) init rewrite engine with requested =20
>>> uri /test/remote.cgi
>>> ... [rid#8aa4900/subreq] (1) pass through /test/remote.cgi
>>> ... [rid#8aa28f8/initial] (5) lookahead: path=3D/test/remote.cgi =20
>>> var=3DREMOTE_USER -> val=3D
>>> ... [rid#8aa28f8/initial] (5) setting env variable 'REMOTE_USER' =20
>>> to ''
>>> ... [rid#8aa28f8/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
>>> ... [rid#8aa28f8/initial] (1) go-ahead with proxy request =20
>>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>>> ... [rid#8aa8908/initial] (2) init rewrite engine with requested =20
>>> uri /test/remote.cgi
>>> ... [rid#8aa8908/initial] (3) applying pattern '^/test$' to uri '/=20=
>>> test/remote.cgi'
>>> ... [rid#8aa8908/initial] (3) applying pattern '^/test/(.*)' to =20
>>> uri '/test/remote.cgi'
>>> ... [rid#8aa8908/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
>>> ... [rid#8abcf90/subreq] (2) init rewrite engine with requested =20
>>> uri /test/remote.cgi
>>> ... [rid#8abcf90/subreq] (1) pass through /test/remote.cgi
>>> ... [rid#8aa8908/initial] (5) lookahead: path=3D/test/remote.cgi =20
>>> var=3DREMOTE_USER -> val=3Ddab66
>>> ... [rid#8aa8908/initial] (5) setting env variable 'REMOTE_USER' =20
>>> to 'dab66'
>>> ... [rid#8aa8908/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
>>> ... [rid#8aa8908/initial] (1) go-ahead with proxy request =20
>>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>>> ------
>>> Any suggestions would be greatly appreciated. Please let me know =20=
>>> if there is any more information I can provide.
>>> Many thanks,
>>> Devin
>>
>>
>> ------------------------------------------------------------ ---------
>> The official User-To-User support forum of the Apache HTTP Server =20
>> Project.
>> See for more info.
>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>> " from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>
--Apple-Mail-10--625194498
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=iso-8859-1
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">I have tried a different approach by moving the RewriteRules into =
the Location directive. With this configuration, the =
HTTP_REMOTE_USER variable is set and visible by the backend script and =
application. However, REMOTE_USER is still blank. Here is =
the alternate =
configuration:
------
<Location =
"/test">
order =
deny,allow
deny from =
all
AuthType =
KerberosV5
AuthName =
"W4restrict"
=
KrbDefaultInstance net
=
Satisfy any
require =
valid-user
RewriteEngine =
on
=
RewriteCond %{REMOTE_USER} (.+)
=
RequestHeader Set Proxy-ip =
%{REMOTE_ADDR}e
RequestHeader =
Set Host ourserver.com:443
=
RequestHeader set REMOTE_USER =
%{REMOTE_USER}e
RewriteRule =
^/var/www/html/test/(.*)
href=3D"http://localhost/cgi-bin/test/$1">http://localhost/c gi-bin/test/$1=
=
[P,L,E=3DREMOTE_USER:%{REMOTE_USER}]
</Location>
>------
And here is what we see in =
rewrite.log:
------
192.168.213.159 - dab66 =
[29/Oct/2009:11:04:47 --0400] [
href=3D"http://ourserver.com/sid#8885358][rid#971a7d0/initia l">ourserver.c=
om/sid#8885358][rid#971a7d0/initial] (3) [per-dir /test/] add path =
info postfix: /var/www/html/test -> =
/var/www/html/test/remote.cgi
192.168.213.159 - dab66 =
[29/Oct/2009:11:04:47 --0400] [
href=3D"http://ourserver.com">ourserver.com/sid#8885358][rid#971a7d0/i=
nitial] (3) [per-dir /test/] applying pattern '^/var/www/html/test/(.*)' =
to uri '/var/www/html/test/remote.cgi'
192.168.213.159 - dab66 =
[29/Oct/2009:11:04:47 --0400] [
href=3D"http://ourserver.com">ourserver.com/sid#8885358][rid#971a7d0/i=
nitial] (4) RewriteCond: input=3D'dab66' pattern=3D'(.+)' =3D> =
matched
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[
href=3D"http://ourserver.com">ourserver.com/sid#8885358][rid#971a7d0/i=
nitial] (2) [per-dir /test/] rewrite /var/www/html/test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
192.168.213.159 - =
dab66 [29/Oct/2009:11:04:47 --0400] [
href=3D"http://ourserver.com">ourserver.com/sid#8885358][rid#971a7d0/i=
nitial] (5) setting env variable 'REMOTE_USER' to =
'dab66'
192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[
href=3D"http://ourserver.com">ourserver.com/sid#8885358][rid#971a7d0/i=
nitial] (2) [per-dir /test/] forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
192.168.213.159 - =
dab66 [29/Oct/2009:11:04:47 --0400] [
href=3D"http://ourserver.com">ourserver.com/sid#8885358][rid#971a7d0/i=
nitial] (1) [per-dir /test/] go-ahead with proxy request =
proxy:http://localhost/cgi-bin/test/remote.cgi =
[OK]
------
Any suggestions for =
passing REMOTE_USER through an Apache proxy would be greatly =
appreciated.
Many =
Thanks,
Devin
On Oct 28, 2009, =
at 4:03 PM, Devin Bougie wrote:
style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; ">
class=3D"Apple-style-span" color=3D"#000000">... For what it's =
worth, I have tried inserting a RewriteCond to make sure the proxy only =
occurs when REMOTE_USER is set. This cleaned up the rewrite.log =
file a bit, but the script is still not able to see REMOTE_USER. =
Here is our updated configuration and =
rewrite.log.
------
######
# =
GlassFish proxy
ProxyPreserveHost =
on
RewriteEngine =
onRe=
writeCond %{LA-U:REMOTE_USER} (.+)
RewriteLog =
/var/log/httpd/rewrite.log
RewriteLogLevel 9
RequestHeader Set =
Proxy-keysize 512
RequestHeader Set Proxy-ip =
%{REMOTE_ADDR}e
RequestHeader Set Host =
ourserver.com:443
RequestHeader set REMOTE_USER =
%{LA-U:REMOTE_USER}e
RewriteRule ^/test$ /test/ =
[R,L]
RewriteRule ^/test/(.*)
href=3D"http://localhost/cgi-bin/test/$1">http://localhost/c gi-bin/test/$1=
[P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
<Location =
"/test">
order =
deny,allow
deny from =
all
AuthType =
KerberosV5
AuthName =
"kerberos authentication"
Satisfy =
any
require =
valid-user
</Location>
------
... =
[rid#8e23fc0/initial] (2) init rewrite engine with requested uri =
/test/remote.cgi
... [rid#8e23fc0/initial] (3) applying =
pattern '^/test$' to uri =
'/test/remote.cgi'
... [rid#8e23fc0/initial] (3) applying =
pattern '^/test/(.*)' to uri =
'/test/remote.cgi'
... [rid#8e23fc0/initial] (2) rewrite =
/test/remote.cgi ->
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... [rid#8e38648/subreq] (2) init =
rewrite engine with requested uri =
/test/remote.cgi
... [rid#8e38648/subreq] (1) pass =
through /test/remote.cgi
... [rid#8e23fc0/initial] (5) =
lookahead: path=3D/test/remote.cgi var=3DREMOTE_USER -> =
val=3Ddab66
... [rid#8e23fc0/initial] (5) setting env =
variable 'REMOTE_USER' to =
'dab66'
... [rid#8e23fc0/initial] (2) forcing =
proxy-throughput with
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... [rid#8e23fc0/initial] (1) =
go-ahead with proxy request =
proxy:http://localhost/cgi-bin/test/remote.cgi =
[OK]
------
Our end goal is to =
proxy from the Apache server to a GlassFish Enterprise Server. =
Just for reference, here is the rewrite.log for a request that's =
proxied to a GlassFish Web =
Application.
------
... [rid#8e23fc8/initial=
] (2) init rewrite engine with requested uri =
/HelloWeb/UserServlet
... [rid#8e23fc8/initial] (3) =
applying pattern '^/HelloWeb$' to uri =
'/HelloWeb/UserServlet'
... [rid#8e23fc8/initial] (3) =
applying pattern '^/HelloWeb/(.*)' to uri =
'/HelloWeb/UserServlet'
... [rid#8e23fc8/initial] (2) =
rewrite /HelloWeb/UserServlet ->
href=3D"http://localhost:38080/HelloWeb/UserServlet">http:// localhost:3808=
0/HelloWeb/UserServlet
... [rid#8e1ffb8/subreq] (2) =
init rewrite engine with requested uri =
/HelloWeb/UserServlet
... [rid#8e1ffb8/subreq] (1) pass =
through /HelloWeb/UserServlet
... [rid#8e23fc8/initial] =
(5) lookahead: path=3D/HelloWeb/UserServlet var=3DREMOTE_USER -> =
val=3Ddab66
... [rid#8e23fc8/initial] (5) setting env =
variable 'REMOTE_USER' to =
'dab66'
... [rid#8e23fc8/initial] (2) forcing =
proxy-throughput with
href=3D"http://localhost:38080/HelloWeb/UserServlet">http:// localhost:3808=
0/HelloWeb/UserServlet
... [rid#8e23fc8/initial] (1) =
go-ahead with proxy request =
proxy:http://localhost:38080/HelloWeb/UserServlet =
[OK]
------
Any suggestions =
would be greatly appreciated.
Thank you =
again,
Devin
On Oct 28, 2009, at 11:15 =
AM, Andr=E9 Warnier wrote:
class=3D"Apple-interchange-newline">
Devin =
Bougie wrote:
...
Hi.
I'll give you my interpretation, =
after looking at the log, not really at the configuration.
I =
think the confusion may be about when and where, things happen exactly. =
And it is not really helped by your choice to proxy from your server to =
itself..
If you examine the log below, you will see =
different/distinct requests, identified by their respective "rid" =
number.
The first is the request rid#8aa28f8 that comes in =
originally, on your "first" server (before the proxying occurs).
That =
one does the proxying before your <Location /test> is even invoked =
(in my opinion). So at that point, the authentication has not even =
happened, and REMOTE_USER is undefined or empty.
That request, you =
then proxy to your "second" server.
Now the proxied request comes =
in to your "second" server. That is request rid#8aa8908. That one =
starts without a REMOTE_USER (see above), but then goes through the =
<Location> section, where it acquires an id.
But by then it is =
too late for proxying..
It would all probably be clearer if you =
set this up in two distinct VirtualHosts, and proxied from the first to =
the second.
Another thing, is that Apache "environment =
variables", are kind of "virtual", in the sense that they exist inside =
of Apache, for the duration of one request.
When you proxy something =
to another server, this is a new request, and this other server does not =
magically inherit the environment of your first request in the first =
server.
To pass it on, you would have to set it in a header which you =
pass to the second server. But then, you must have a value to =
pass, by the time you create the header.
Which does not seem to be =
the case here.
Hope that is clear.
As for me, I think I need a =
cup of coffee now.
type=3D"cite">------
type=3D"cite">######
# =
GlassFish proxy
type=3D"cite">ProxyPreserveHost =
on
type=3D"cite">RewriteEngine =
on
uote>
RewriteLog =
/var/log/httpd/rewrite.log
type=3D"cite">RewriteLogLevel 9
type=3D"cite">RequestHeader Set Proxy-keysize =
512
RequestHeader Set Proxy-ip =
%{REMOTE_ADDR}e
RequestHeader =
Set Host ourserver.com:443
type=3D"cite">RequestHeader set REMOTE_USER =
%{LA-U:REMOTE_USER}e
RewriteRule=
^/test$ /test/ [R,L]
type=3D"cite">RewriteRule ^/test/(.*)
href=3D"http://localhost/cgi-bin/test/$1">http://localhost/c gi-bin/test/$1=
[P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
type=3D"cite"><Location "/test">
type=3D"cite"> order =
deny,allow
=
deny from =
all
=
AuthType =
KerberosV5
=
AuthName "kerberos =
authentication"
=
Satisfy =
any
=
require =
valid-user
type=3D"cite"></Location>
type=3D"cite">------
And here =
is what I see in rewrite.log. REMOTE_USER is eventually set =
properly, just not soon enough for the =
script.
type=3D"cite">------
... =
[rid#8aa28f8/initial] (2) init rewrite engine with requested uri =
/test/remote.cgi
... =
[rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri =
'/test/remote.cgi'
... =
[rid#8aa28f8/initial] (3) applying pattern '^/test/(.*)' to uri =
'/test/remote.cgi'
... =
[rid#8aa28f8/initial] (2) rewrite /test/remote.cgi ->
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... =
[rid#8aa4900/subreq] (2) init rewrite engine with requested uri =
/test/remote.cgi
... =
[rid#8aa4900/subreq] (1) pass through =
/test/remote.cgi
... =
[rid#8aa28f8/initial] (5) lookahead: path=3D/test/remote.cgi =
var=3DREMOTE_USER -> val=3D
type=3D"cite">... [rid#8aa28f8/initial] (5) setting env variable =
'REMOTE_USER' to ''
... =
[rid#8aa28f8/initial] (2) forcing proxy-throughput with
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... =
[rid#8aa28f8/initial] (1) go-ahead with proxy request =
proxy:http://localhost/cgi-bin/test/remote.cgi =
[OK]
... [rid#8aa8908/initial] =
(2) init rewrite engine with requested uri =
/test/remote.cgi
... =
[rid#8aa8908/initial] (3) applying pattern '^/test$' to uri =
'/test/remote.cgi'
... =
[rid#8aa8908/initial] (3) applying pattern '^/test/(.*)' to uri =
'/test/remote.cgi'
... =
[rid#8aa8908/initial] (2) rewrite /test/remote.cgi ->
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... =
[rid#8abcf90/subreq] (2) init rewrite engine with requested uri =
/test/remote.cgi
... =
[rid#8abcf90/subreq] (1) pass through =
/test/remote.cgi
... =
[rid#8aa8908/initial] (5) lookahead: path=3D/test/remote.cgi =
var=3DREMOTE_USER -> val=3Ddab66
type=3D"cite">... [rid#8aa8908/initial] (5) setting env variable =
'REMOTE_USER' to 'dab66'
... =
[rid#8aa8908/initial] (2) forcing proxy-throughput with
href=3D"http://localhost/cgi-bin/test/remote.cgi">http://loc alhost/cgi-bin=
/test/remote.cgi
... =
[rid#8aa8908/initial] (1) go-ahead with proxy request =
proxy:http://localhost/cgi-bin/test/remote.cgi =
[OK]
type=3D"cite">------
Any =
suggestions would be greatly appreciated. Please let me know if =
there is any more information I can provide.
type=3D"cite">Many thanks,
type=3D"cite">Devin
------------------------------=
---------------------------------------
The official User-To-User =
support forum of the Apache HTTP Server Project.
See =
<URL:http://httpd.apache.org/userslist.html> for more info.
To =
unsubscribe, e-mail:
href=3D"mailto:users-unsubscribe@httpd.apache.org">users-uns ubscribe@httpd=
..apache.org
" from the digest:
href=3D"mailto:users-digest-unsubscribe@httpd.apache.org">us ers-digest-uns=
ubscribe@httpd.apache.org
For additional commands, e-mail:
href=3D"mailto:users-help@httpd.apache.org">users-help@httpd .apache.org
>
>
=
--Apple-Mail-10--625194498--
Re: accessing REMOTE_USER through an Apache proxy
am 30.10.2009 00:48:07 von aw
Devin,
I still have some lingering doubt about whether there is not a confusion
somewhere between
- the Apache process's environment values (what it gets in its own
environment when it starts up)
- the Apache "internal environment variables" (set internally by Apache,
for Apache only, during one request), which when using the mod_jk
connector to forward requests to Tomcat via AJP, become known as
"request attributes" (a better name, in my opinion, less confusing)
- HTTP request headers and their content
- cgi-bin environment values (set by Apache in the environment of a
child process just prior to running the cgi program in it).
All these things above are distinct animals. Apache does for instance
take the value of /some/ HTTP request headers, and translates them into
/some/ environment values for cgi-bin programs, but the HTTP request
headers and cgi-bin environment values are distinct items, and there is
not a one-to-one relationship between them. They do not even necessarily
have the same name.
It took me a while to "click" on this, but I believe that what you are
seeing with your cgi-bin script is :
- your Apache setup sets a HTTP Header "REMOTE_USER", and proxies that
modified request
- the request is received by (another instance of) Apache, which calls a
cgi-bin script to handle it.
- prior to calling the cgi-bin script, Apache picks up the content of
the HTTP header named "REMOTE_USER", and sets up that content as a
*cgi-bin environment variable* named "HTTP_REMOTE_USER".
- then in your cgi script, you are not looking at the HTTP header
"REMOTE_USER" (which was received by Apache), but you are looking for an
*environment variable* "REMOTE_USER", which is not there.
It is not there because the cgi-bin environment variable (as set by
Apache) is named "HTTP_REMOTE_USER".
Get the difference ?
A cgi-bin script does not, in general, have access to the HTTP headers
that came in with the request which caused Apache to run this cgi-bin
script.
Instead, Apache "translates" *some* of these request HTTP headers into
cgi-bin environment variables, to which the cgi-bin program *does* have
access.
(For example, Apache also splits off the query-string part of the
request URL, and passes it to the cgi-bin program as the environment
variable QUERY_STRING. But that was never a HTTP request header.)
- But when you are going to pass this request to Glassfish, Apache is
not going to set up environment values for Glassfish. It is going to
pass HTTP headers. And one of them *will* be "REMOTE_USER:".
So in fact you have already solved your problem.
You are just testing it with the wrong tool.
If your Apache server is set up with mod_perl, I could give you a Perl
cgi-bin script which would show you the difference.
That's because under mod_perl, Perl cgi-bin scripts *can* ask Apache for
the original HTTP request headers.
Devin Bougie wrote:
> I have tried a different approach by moving the RewriteRules into the
> Location directive. With this configuration, the HTTP_REMOTE_USER
> variable is set and visible by the backend script and application.
> However, REMOTE_USER is still blank. Here is the alternate configuration:
> ------
>
> order deny,allow
> deny from all
> AuthType KerberosV5
> AuthName "W4restrict"
> KrbDefaultInstance net
> Satisfy any
> require valid-user
> RewriteEngine on
> RewriteCond %{REMOTE_USER} (.+)
> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
> RequestHeader Set Host ourserver.com:443
> RequestHeader set REMOTE_USER %{REMOTE_USER}e
> RewriteRule ^/var/www/html/test/(.*)
> http://localhost/cgi-bin/test/$1 [P,L,E=REMOTE_USER:%{REMOTE_USER}]
>
> ------
> And here is what we see in rewrite.log:
> ------
> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400]
> [ourserver.com/sid#8885358][rid#971a7d0/initial] (3) [per-dir /test/]
> add path info postfix: /var/www/html/test -> /var/www/html/test/remote.cgi
> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400]
> [ourserver.com/sid#8885358][rid#971a7d0/initial] (3) [per-dir /test/]
> applying pattern '^/var/www/html/test/(.*)' to uri
> '/var/www/html/test/remote.cgi'
> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400]
> [ourserver.com/sid#8885358][rid#971a7d0/initial] (4) RewriteCond:
> input='dab66' pattern='(.+)' => matched
> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400]
> [ourserver.com/sid#8885358][rid#971a7d0/initial] (2) [per-dir /test/]
> rewrite /var/www/html/test/remote.cgi ->
> http://localhost/cgi-bin/test/remote.cgi
> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400]
> [ourserver.com/sid#8885358][rid#971a7d0/initial] (5) setting env
> variable 'REMOTE_USER' to 'dab66'
> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400]
> [ourserver.com/sid#8885358][rid#971a7d0/initial] (2) [per-dir /test/]
> forcing proxy-throughput with http://localhost/cgi-bin/test/remote.cgi
> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400]
> [ourserver.com/sid#8885358][rid#971a7d0/initial] (1) [per-dir /test/]
> go-ahead with proxy request
> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
> ------
>
> Any suggestions for passing REMOTE_USER through an Apache proxy would be
> greatly appreciated.
>
> Many Thanks,
> Devin
>
> On Oct 28, 2009, at 4:03 PM, Devin Bougie wrote:
>> ... For what it's worth, I have tried inserting a RewriteCond to make
>> sure the proxy only occurs when REMOTE_USER is set. This cleaned up
>> the rewrite.log file a bit, but the script is still not able to see
>> REMOTE_USER. Here is our updated configuration and rewrite.log.
>>
>> ------
>> ######
>> # GlassFish proxy
>> ProxyPreserveHost on
>>
>> RewriteEngine on
>> RewriteCond %{LA-U:REMOTE_USER} (.+)
>> RewriteLog /var/log/httpd/rewrite.log
>> RewriteLogLevel 9
>>
>> RequestHeader Set Proxy-keysize 512
>> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
>> RequestHeader Set Host ourserver.com:443
>> RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
>>
>> RewriteRule ^/test$ /test/ [R,L]
>> RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1
>> [P,L,E=REMOTE_USER:%{LA-U:REMOTE_USER}]
>>
>> order deny,allow
>> deny from all
>> AuthType KerberosV5
>> AuthName "kerberos authentication"
>> Satisfy any
>> require valid-user
>>
>> ------
>> ... [rid#8e23fc0/initial] (2) init rewrite engine with requested uri
>> /test/remote.cgi
>> ... [rid#8e23fc0/initial] (3) applying pattern '^/test$' to uri
>> '/test/remote.cgi'
>> ... [rid#8e23fc0/initial] (3) applying pattern '^/test/(.*)' to uri
>> '/test/remote.cgi'
>> ... [rid#8e23fc0/initial] (2) rewrite /test/remote.cgi ->
>> http://localhost/cgi-bin/test/remote.cgi
>> ... [rid#8e38648/subreq] (2) init rewrite engine with requested uri
>> /test/remote.cgi
>> ... [rid#8e38648/subreq] (1) pass through /test/remote.cgi
>> ... [rid#8e23fc0/initial] (5) lookahead: path=/test/remote.cgi
>> var=REMOTE_USER -> val=dab66
>> ... [rid#8e23fc0/initial] (5) setting env variable 'REMOTE_USER' to
>> 'dab66'
>> ... [rid#8e23fc0/initial] (2) forcing proxy-throughput with
>> http://localhost/cgi-bin/test/remote.cgi
>> ... [rid#8e23fc0/initial] (1) go-ahead with proxy request
>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>> ------
>>
>> Our end goal is to proxy from the Apache server to a GlassFish
>> Enterprise Server. Just for reference, here is the rewrite.log for a
>> request that's proxied to a GlassFish Web Application.
>> ------
>> ... [rid#8e23fc8/initial] (2) init rewrite engine with requested uri
>> /HelloWeb/UserServlet
>> ... [rid#8e23fc8/initial] (3) applying pattern '^/HelloWeb$' to uri
>> '/HelloWeb/UserServlet'
>> ... [rid#8e23fc8/initial] (3) applying pattern '^/HelloWeb/(.*)' to
>> uri '/HelloWeb/UserServlet'
>> ... [rid#8e23fc8/initial] (2) rewrite /HelloWeb/UserServlet ->
>> http://localhost:38080/HelloWeb/UserServlet
>> ... [rid#8e1ffb8/subreq] (2) init rewrite engine with requested uri
>> /HelloWeb/UserServlet
>> ... [rid#8e1ffb8/subreq] (1) pass through /HelloWeb/UserServlet
>> ... [rid#8e23fc8/initial] (5) lookahead: path=/HelloWeb/UserServlet
>> var=REMOTE_USER -> val=dab66
>> ... [rid#8e23fc8/initial] (5) setting env variable 'REMOTE_USER' to
>> 'dab66'
>> ... [rid#8e23fc8/initial] (2) forcing proxy-throughput with
>> http://localhost:38080/HelloWeb/UserServlet
>> ... [rid#8e23fc8/initial] (1) go-ahead with proxy request
>> proxy:http://localhost:38080/HelloWeb/UserServlet [OK]
>> ------
>>
>> Any suggestions would be greatly appreciated.
>>
>> Thank you again,
>> Devin
>>
>> On Oct 28, 2009, at 11:15 AM, André Warnier wrote:
>>
>>> Devin Bougie wrote:
>>> ...
>>>
>>> Hi.
>>>
>>> I'll give you my interpretation, after looking at the log, not really
>>> at the configuration.
>>>
>>> I think the confusion may be about when and where, things happen
>>> exactly. And it is not really helped by your choice to proxy from
>>> your server to itself..
>>>
>>> If you examine the log below, you will see different/distinct
>>> requests, identified by their respective "rid" number.
>>>
>>> The first is the request rid#8aa28f8 that comes in originally, on
>>> your "first" server (before the proxying occurs).
>>> That one does the proxying before your is even
>>> invoked (in my opinion). So at that point, the authentication has
>>> not even happened, and REMOTE_USER is undefined or empty.
>>> That request, you then proxy to your "second" server.
>>>
>>> Now the proxied request comes in to your "second" server. That is
>>> request rid#8aa8908. That one starts without a REMOTE_USER (see
>>> above), but then goes through the section, where it
>>> acquires an id.
>>> But by then it is too late for proxying..
>>>
>>> It would all probably be clearer if you set this up in two distinct
>>> VirtualHosts, and proxied from the first to the second.
>>>
>>> Another thing, is that Apache "environment variables", are kind of
>>> "virtual", in the sense that they exist inside of Apache, for the
>>> duration of one request.
>>> When you proxy something to another server, this is a new request,
>>> and this other server does not magically inherit the environment of
>>> your first request in the first server.
>>> To pass it on, you would have to set it in a header which you pass to
>>> the second server. But then, you must have a value to pass, by the
>>> time you create the header.
>>> Which does not seem to be the case here.
>>>
>>> Hope that is clear.
>>> As for me, I think I need a cup of coffee now.
>>>
>>>
>>>> ------
>>>> ######
>>>> # GlassFish proxy
>>>> ProxyPreserveHost on
>>>> RewriteEngine on
>>>> RewriteLog /var/log/httpd/rewrite.log
>>>> RewriteLogLevel 9
>>>> RequestHeader Set Proxy-keysize 512
>>>> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
>>>> RequestHeader Set Host ourserver.com:443
>>>> RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
>>>> RewriteRule ^/test$ /test/ [R,L]
>>>> RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1
>>>> [P,L,E=REMOTE_USER:%{LA-U:REMOTE_USER}]
>>>>
>>>> order deny,allow
>>>> deny from all
>>>> AuthType KerberosV5
>>>> AuthName "kerberos authentication"
>>>> Satisfy any
>>>> require valid-user
>>>>
>>>> ------
>>>> And here is what I see in rewrite.log. REMOTE_USER is eventually
>>>> set properly, just not soon enough for the script.
>>>> ------
>>>> ... [rid#8aa28f8/initial] (2) init rewrite engine with requested uri
>>>> /test/remote.cgi
>>>> ... [rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri
>>>> '/test/remote.cgi'
>>>> ... [rid#8aa28f8/initial] (3) applying pattern '^/test/(.*)' to uri
>>>> '/test/remote.cgi'
>>>> ... [rid#8aa28f8/initial] (2) rewrite /test/remote.cgi ->
>>>> http://localhost/cgi-bin/test/remote.cgi
>>>> ... [rid#8aa4900/subreq] (2) init rewrite engine with requested uri
>>>> /test/remote.cgi
>>>> ... [rid#8aa4900/subreq] (1) pass through /test/remote.cgi
>>>> ... [rid#8aa28f8/initial] (5) lookahead: path=/test/remote.cgi
>>>> var=REMOTE_USER -> val=
>>>> ... [rid#8aa28f8/initial] (5) setting env variable 'REMOTE_USER' to ''
>>>> ... [rid#8aa28f8/initial] (2) forcing proxy-throughput with
>>>> http://localhost/cgi-bin/test/remote.cgi
>>>> ... [rid#8aa28f8/initial] (1) go-ahead with proxy request
>>>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>>>> ... [rid#8aa8908/initial] (2) init rewrite engine with requested uri
>>>> /test/remote.cgi
>>>> ... [rid#8aa8908/initial] (3) applying pattern '^/test$' to uri
>>>> '/test/remote.cgi'
>>>> ... [rid#8aa8908/initial] (3) applying pattern '^/test/(.*)' to uri
>>>> '/test/remote.cgi'
>>>> ... [rid#8aa8908/initial] (2) rewrite /test/remote.cgi ->
>>>> http://localhost/cgi-bin/test/remote.cgi
>>>> ... [rid#8abcf90/subreq] (2) init rewrite engine with requested uri
>>>> /test/remote.cgi
>>>> ... [rid#8abcf90/subreq] (1) pass through /test/remote.cgi
>>>> ... [rid#8aa8908/initial] (5) lookahead: path=/test/remote.cgi
>>>> var=REMOTE_USER -> val=dab66
>>>> ... [rid#8aa8908/initial] (5) setting env variable 'REMOTE_USER' to
>>>> 'dab66'
>>>> ... [rid#8aa8908/initial] (2) forcing proxy-throughput with
>>>> http://localhost/cgi-bin/test/remote.cgi
>>>> ... [rid#8aa8908/initial] (1) go-ahead with proxy request
>>>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>>>> ------
>>>> Any suggestions would be greatly appreciated. Please let me know if
>>>> there is any more information I can provide.
>>>> Many thanks,
>>>> Devin
>>>
>>>
>>> ------------------------------------------------------------ ---------
>>> The official User-To-User support forum of the Apache HTTP Server
>>> Project.
>>> See for more info.
>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>> " from the digest: users-digest-unsubscribe@httpd.apache.org
>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>
>>
>
>
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: accessing REMOTE_USER through an Apache proxy
am 30.10.2009 17:30:42 von Devin Bougie
Hi Andr=E9,
Thank you very much for another thorough explanation. This certainly =20=
does help clear up my confusion. With the latest posted =20
configuration, I am able to see the REMOTE_USER HTTP header from the =20
backend GlassFish Web Application (using HttpServletRequest.getHeader=20
("REMOTE_USER")). As you explain, HttpServletRequest.getRemoteUser =20
and getUserPrincipal both return null because they are looking for the =20=
REMOTE_USER cgi-bin environment variable.
For what it's worth, here is an excerpt from the CGI script I was =20
testing with. When calling the script directly, $REMOTE_USER is set =20
but $HTTP_REMOTE_USER is not. When accessing the script through the =20
proxy (using the latest posted configuration), $HTTP_REMOTE_USER is =20
set but $REMOTE_USER is not.
------
# test for $REMOTE_USER
if [ -z "$REMOTE_USER" ]; then
echo '$REMOTE_USER not set.'
else echo "REMOTE_USER is $REMOTE_USER"
fi
# test for $HTTP_REMOTE_USER
if [ -z "$HTTP_REMOTE_USER" ]; then
echo '$HTTP_REMOTE_USER not set.'
else echo "HTTP_REMOTE_USER is $HTTP_REMOTE_USER"
fi
echo ''
echo 'Environment is:'
printenv
------
I believe being able to access the REMOTE_USER HTTP header achieves =20
our goal. Thank you very much for all of your time and help.
Sincerely,
Devin
> I still have some lingering doubt about whether there is not a =20
> confusion somewhere between
> - the Apache process's environment values (what it gets in its own =20
> environment when it starts up)
> - the Apache "internal environment variables" (set internally by =20
> Apache, for Apache only, during one request), which when using the =20
> mod_jk connector to forward requests to Tomcat via AJP, become known =20=
> as "request attributes" (a better name, in my opinion, less confusing)
> - HTTP request headers and their content
> - cgi-bin environment values (set by Apache in the environment of a =20=
> child process just prior to running the cgi program in it).
>
> All these things above are distinct animals. Apache does for =20
> instance take the value of /some/ HTTP request headers, and =20
> translates them into /some/ environment values for cgi-bin programs, =20=
> but the HTTP request headers and cgi-bin environment values are =20
> distinct items, and there is not a one-to-one relationship between =20
> them. They do not even necessarily have the same name.
>
> It took me a while to "click" on this, but I believe that what you =20
> are seeing with your cgi-bin script is :
> - your Apache setup sets a HTTP Header "REMOTE_USER", and proxies =20
> that modified request
> - the request is received by (another instance of) Apache, which =20
> calls a cgi-bin script to handle it.
> - prior to calling the cgi-bin script, Apache picks up the content =20
> of the HTTP header named "REMOTE_USER", and sets up that content as =20=
> a *cgi-bin environment variable* named "HTTP_REMOTE_USER".
> - then in your cgi script, you are not looking at the HTTP header =20
> "REMOTE_USER" (which was received by Apache), but you are looking =20
> for an *environment variable* "REMOTE_USER", which is not there.
> It is not there because the cgi-bin environment variable (as set by =20=
> Apache) is named "HTTP_REMOTE_USER".
> Get the difference ?
>
> A cgi-bin script does not, in general, have access to the HTTP =20
> headers that came in with the request which caused Apache to run =20
> this cgi-bin script.
> Instead, Apache "translates" *some* of these request HTTP headers =20
> into cgi-bin environment variables, to which the cgi-bin program =20
> *does* have access.
> (For example, Apache also splits off the query-string part of the =20
> request URL, and passes it to the cgi-bin program as the environment =20=
> variable QUERY_STRING. But that was never a HTTP request header.)
>
> - But when you are going to pass this request to Glassfish, Apache =20
> is not going to set up environment values for Glassfish. It is =20
> going to pass HTTP headers. And one of them *will* be "REMOTE_USER:".
>
> So in fact you have already solved your problem.
> You are just testing it with the wrong tool.
> If your Apache server is set up with mod_perl, I could give you a =20
> Perl cgi-bin script which would show you the difference.
> That's because under mod_perl, Perl cgi-bin scripts *can* ask Apache =20=
> for the original HTTP request headers.
>
>
> Devin Bougie wrote:
>> I have tried a different approach by moving the RewriteRules into =20
>> the Location directive. With this configuration, the =20
>> HTTP_REMOTE_USER variable is set and visible by the backend script =20=
>> and application. However, REMOTE_USER is still blank. Here is the =20=
>> alternate configuration:
>> ------
>>
>> order deny,allow
>> deny from all
>> AuthType KerberosV5
>> AuthName "W4restrict"
>> KrbDefaultInstance net
>> Satisfy any
>> require valid-user
>> RewriteEngine on
>> RewriteCond %{REMOTE_USER} (.+)
>> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
>> RequestHeader Set Host ourserver.com:443
>> RequestHeader set REMOTE_USER %{REMOTE_USER}e
>> RewriteRule ^/var/www/html/test/(.*) =
http://localhost/cgi-bin/test/$1=20
>> [P,L,E=3DREMOTE_USER:%{REMOTE_USER}]
>>
>> ------
>> And here is what we see in rewrite.log:
>> ------
>> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
>> ] (3) [per-dir /test/] add path info postfix: /var/www/html/test -=20
>> > /var/www/html/test/remote.cgi
>> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
>> ] (3) [per-dir /test/] applying pattern '^/var/www/html/test/(.*)' =20=
>> to uri '/var/www/html/test/remote.cgi'
>> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
>> ] (4) RewriteCond: input=3D'dab66' pattern=3D'(.+)' =3D> matched
>> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
>> ] (2) [per-dir /test/] rewrite /var/www/html/test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
>> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
>> ] (5) setting env variable 'REMOTE_USER' to 'dab66'
>> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
>> ] (2) [per-dir /test/] forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
>> 192.168.213.159 - dab66 [29/Oct/2009:11:04:47 --0400] =
[ourserver.com/sid#8885358][rid#971a7d0/initial=20
>> ] (1) [per-dir /test/] go-ahead with proxy request proxy:http://=20
>> localhost/cgi-bin/test/remote.cgi [OK]
>> ------
>> Any suggestions for passing REMOTE_USER through an Apache proxy =20
>> would be greatly appreciated.
>> Many Thanks,
>> Devin
>> On Oct 28, 2009, at 4:03 PM, Devin Bougie wrote:
>>> ... For what it's worth, I have tried inserting a RewriteCond to =20
>>> make sure the proxy only occurs when REMOTE_USER is set. This =20
>>> cleaned up the rewrite.log file a bit, but the script is still not =20=
>>> able to see REMOTE_USER. Here is our updated configuration and =20
>>> rewrite.log.
>>>
>>> ------
>>> ######
>>> # GlassFish proxy
>>> ProxyPreserveHost on
>>>
>>> RewriteEngine on
>>> RewriteCond %{LA-U:REMOTE_USER} (.+)
>>> RewriteLog /var/log/httpd/rewrite.log
>>> RewriteLogLevel 9
>>>
>>> RequestHeader Set Proxy-keysize 512
>>> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
>>> RequestHeader Set Host ourserver.com:443
>>> RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
>>>
>>> RewriteRule ^/test$ /test/ [R,L]
>>> RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1 =20
>>> [P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
>>>
>>> order deny,allow
>>> deny from all
>>> AuthType KerberosV5
>>> AuthName "kerberos authentication"
>>> Satisfy any
>>> require valid-user
>>>
>>> ------
>>> ... [rid#8e23fc0/initial] (2) init rewrite engine with requested =20
>>> uri /test/remote.cgi
>>> ... [rid#8e23fc0/initial] (3) applying pattern '^/test$' to uri '/=20=
>>> test/remote.cgi'
>>> ... [rid#8e23fc0/initial] (3) applying pattern '^/test/(.*)' to =20
>>> uri '/test/remote.cgi'
>>> ... [rid#8e23fc0/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
>>> ... [rid#8e38648/subreq] (2) init rewrite engine with requested =20
>>> uri /test/remote.cgi
>>> ... [rid#8e38648/subreq] (1) pass through /test/remote.cgi
>>> ... [rid#8e23fc0/initial] (5) lookahead: path=3D/test/remote.cgi =20
>>> var=3DREMOTE_USER -> val=3Ddab66
>>> ... [rid#8e23fc0/initial] (5) setting env variable 'REMOTE_USER' =20
>>> to 'dab66'
>>> ... [rid#8e23fc0/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
>>> ... [rid#8e23fc0/initial] (1) go-ahead with proxy request =20
>>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>>> ------
>>>
>>> Our end goal is to proxy from the Apache server to a GlassFish =20
>>> Enterprise Server. Just for reference, here is the rewrite.log =20
>>> for a request that's proxied to a GlassFish Web Application.
>>> ------
>>> ... [rid#8e23fc8/initial] (2) init rewrite engine with requested =20
>>> uri /HelloWeb/UserServlet
>>> ... [rid#8e23fc8/initial] (3) applying pattern '^/HelloWeb$' to =20
>>> uri '/HelloWeb/UserServlet'
>>> ... [rid#8e23fc8/initial] (3) applying pattern '^/HelloWeb/(.*)' =20
>>> to uri '/HelloWeb/UserServlet'
>>> ... [rid#8e23fc8/initial] (2) rewrite /HelloWeb/UserServlet -> =
http://localhost:38080/HelloWeb/UserServlet
>>> ... [rid#8e1ffb8/subreq] (2) init rewrite engine with requested =20
>>> uri /HelloWeb/UserServlet
>>> ... [rid#8e1ffb8/subreq] (1) pass through /HelloWeb/UserServlet
>>> ... [rid#8e23fc8/initial] (5) lookahead: path=3D/HelloWeb/=20
>>> UserServlet var=3DREMOTE_USER -> val=3Ddab66
>>> ... [rid#8e23fc8/initial] (5) setting env variable 'REMOTE_USER' =20
>>> to 'dab66'
>>> ... [rid#8e23fc8/initial] (2) forcing proxy-throughput with =
http://localhost:38080/HelloWeb/UserServlet
>>> ... [rid#8e23fc8/initial] (1) go-ahead with proxy request =20
>>> proxy:http://localhost:38080/HelloWeb/UserServlet [OK]
>>> ------
>>>
>>> Any suggestions would be greatly appreciated.
>>>
>>> Thank you again,
>>> Devin
>>>
>>> On Oct 28, 2009, at 11:15 AM, Andr=E9 Warnier wrote:
>>>
>>>> Devin Bougie wrote:
>>>> ...
>>>>
>>>> Hi.
>>>>
>>>> I'll give you my interpretation, after looking at the log, not =20
>>>> really at the configuration.
>>>>
>>>> I think the confusion may be about when and where, things happen =20=
>>>> exactly. And it is not really helped by your choice to proxy from =20=
>>>> your server to itself..
>>>>
>>>> If you examine the log below, you will see different/distinct =20
>>>> requests, identified by their respective "rid" number.
>>>>
>>>> The first is the request rid#8aa28f8 that comes in originally, on =20=
>>>> your "first" server (before the proxying occurs).
>>>> That one does the proxying before your is even =20
>>>> invoked (in my opinion). So at that point, the authentication =20
>>>> has not even happened, and REMOTE_USER is undefined or empty.
>>>> That request, you then proxy to your "second" server.
>>>>
>>>> Now the proxied request comes in to your "second" server. That is =20=
>>>> request rid#8aa8908. That one starts without a REMOTE_USER (see =20=
>>>> above), but then goes through the section, where it =20
>>>> acquires an id.
>>>> But by then it is too late for proxying..
>>>>
>>>> It would all probably be clearer if you set this up in two =20
>>>> distinct VirtualHosts, and proxied from the first to the second.
>>>>
>>>> Another thing, is that Apache "environment variables", are kind =20
>>>> of "virtual", in the sense that they exist inside of Apache, for =20=
>>>> the duration of one request.
>>>> When you proxy something to another server, this is a new =20
>>>> request, and this other server does not magically inherit the =20
>>>> environment of your first request in the first server.
>>>> To pass it on, you would have to set it in a header which you =20
>>>> pass to the second server. But then, you must have a value to =20
>>>> pass, by the time you create the header.
>>>> Which does not seem to be the case here.
>>>>
>>>> Hope that is clear.
>>>> As for me, I think I need a cup of coffee now.
>>>>
>>>>
>>>>> ------
>>>>> ######
>>>>> # GlassFish proxy
>>>>> ProxyPreserveHost on
>>>>> RewriteEngine on
>>>>> RewriteLog /var/log/httpd/rewrite.log
>>>>> RewriteLogLevel 9
>>>>> RequestHeader Set Proxy-keysize 512
>>>>> RequestHeader Set Proxy-ip %{REMOTE_ADDR}e
>>>>> RequestHeader Set Host ourserver.com:443
>>>>> RequestHeader set REMOTE_USER %{LA-U:REMOTE_USER}e
>>>>> RewriteRule ^/test$ /test/ [R,L]
>>>>> RewriteRule ^/test/(.*) http://localhost/cgi-bin/test/$1 =20
>>>>> [P,L,E=3DREMOTE_USER:%{LA-U:REMOTE_USER}]
>>>>>
>>>>> order deny,allow
>>>>> deny from all
>>>>> AuthType KerberosV5
>>>>> AuthName "kerberos authentication"
>>>>> Satisfy any
>>>>> require valid-user
>>>>>
>>>>> ------
>>>>> And here is what I see in rewrite.log. REMOTE_USER is =20
>>>>> eventually set properly, just not soon enough for the script.
>>>>> ------
>>>>> ... [rid#8aa28f8/initial] (2) init rewrite engine with requested =20=
>>>>> uri /test/remote.cgi
>>>>> ... [rid#8aa28f8/initial] (3) applying pattern '^/test$' to uri =20=
>>>>> '/test/remote.cgi'
>>>>> ... [rid#8aa28f8/initial] (3) applying pattern '^/test/(.*)' to =20=
>>>>> uri '/test/remote.cgi'
>>>>> ... [rid#8aa28f8/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
>>>>> ... [rid#8aa4900/subreq] (2) init rewrite engine with requested =20=
>>>>> uri /test/remote.cgi
>>>>> ... [rid#8aa4900/subreq] (1) pass through /test/remote.cgi
>>>>> ... [rid#8aa28f8/initial] (5) lookahead: path=3D/test/remote.cgi =20=
>>>>> var=3DREMOTE_USER -> val=3D
>>>>> ... [rid#8aa28f8/initial] (5) setting env variable 'REMOTE_USER' =20=
>>>>> to ''
>>>>> ... [rid#8aa28f8/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
>>>>> ... [rid#8aa28f8/initial] (1) go-ahead with proxy request =20
>>>>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>>>>> ... [rid#8aa8908/initial] (2) init rewrite engine with requested =20=
>>>>> uri /test/remote.cgi
>>>>> ... [rid#8aa8908/initial] (3) applying pattern '^/test$' to uri =20=
>>>>> '/test/remote.cgi'
>>>>> ... [rid#8aa8908/initial] (3) applying pattern '^/test/(.*)' to =20=
>>>>> uri '/test/remote.cgi'
>>>>> ... [rid#8aa8908/initial] (2) rewrite /test/remote.cgi -> =
http://localhost/cgi-bin/test/remote.cgi
>>>>> ... [rid#8abcf90/subreq] (2) init rewrite engine with requested =20=
>>>>> uri /test/remote.cgi
>>>>> ... [rid#8abcf90/subreq] (1) pass through /test/remote.cgi
>>>>> ... [rid#8aa8908/initial] (5) lookahead: path=3D/test/remote.cgi =20=
>>>>> var=3DREMOTE_USER -> val=3Ddab66
>>>>> ... [rid#8aa8908/initial] (5) setting env variable 'REMOTE_USER' =20=
>>>>> to 'dab66'
>>>>> ... [rid#8aa8908/initial] (2) forcing proxy-throughput with =
http://localhost/cgi-bin/test/remote.cgi
>>>>> ... [rid#8aa8908/initial] (1) go-ahead with proxy request =20
>>>>> proxy:http://localhost/cgi-bin/test/remote.cgi [OK]
>>>>> ------
>>>>> Any suggestions would be greatly appreciated. Please let me =20
>>>>> know if there is any more information I can provide.
>>>>> Many thanks,
>>>>> Devin
>>>>
>>>>
>>>> =
------------------------------------------------------------ ---------
>>>> The official User-To-User support forum of the Apache HTTP Server =20=
>>>> Project.
>>>> See for more info.
>>>> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>>>> " from the digest: users-digest-unsubscribe@httpd.apache.org
>>>> For additional commands, e-mail: users-help@httpd.apache.org
>>>>
>>>
>
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server =20
> Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: accessing REMOTE_USER through an Apache proxy
am 30.10.2009 17:49:04 von aw
Hi.
Glad to have been of help.
One more nitpick however, below, lest you remain partly confused.
Devin Bougie wrote:
....
With the latest posted configuration,
> I am able to see the REMOTE_USER HTTP header from the backend GlassFish
> Web Application (using HttpServletRequest.getHeader("REMOTE_USER")).
OK, and correct.
As
> you explain, HttpServletRequest.getRemoteUser and getUserPrincipal both
> return null because they are looking for the REMOTE_USER cgi-bin
> environment variable.
No, they are not.
A cgi-bin environment variable is only set by a webserver when running a
cgi-bin program.
A servlet is not a cgi-bin program, and the servlet container which runs
it, does not set any "environment variables" for the servlet.
If HttpServletRequest.getRemoteUser and
HttpServletRequest.getUserPrincipal return null, it is because they both
look into the UserPrincipal object, which is probably not set, because
you have not done any authentication (yet) in your servlet container.
You have just read a HTTP header, and gotten back a String as a result.
That does not, for the servlet container, constitute reason enough to
take that String, consider it as a bona fide user-id, and set it into
the UserPrincipal object so that HttpServletRequest.getRemoteUser would
nicely return it. Hence the nulls.
So it looks like you still have some work to do.
But that is now a question which belongs to the GlassFish forum.
------------------------------------------------------------ ---------
The official User-To-User support forum of the Apache HTTP Server Project.
See for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: accessing REMOTE_USER through an Apache proxy
am 30.10.2009 18:01:45 von Devin Bougie
--Apple-Mail-24--557968867
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=iso-8859-1;
format=flowed;
delsp=yes
On Oct 30, 2009, at 12:49 PM, Andr=E9 Warnier wrote:
> Glad to have been of help.
> One more nitpick however, below, lest you remain partly confused.
Yes, indeed. I was confused by the "Same as the value of the CGI =20
variable REMOTE_USER." statement in the =20
HttpServletRequest.getRemoteUser javadoc, but you have again helped =20
explain that.
Thanks again,
Devin
>
> Devin Bougie wrote:
> ...
>
> With the latest posted configuration,
>> I am able to see the REMOTE_USER HTTP header from the backend =20
>> GlassFish Web Application (using HttpServletRequest.getHeader=20
>> ("REMOTE_USER")).
> OK, and correct.
>
> As
>> you explain, HttpServletRequest.getRemoteUser and getUserPrincipal =20=
>> both return null because they are looking for the REMOTE_USER cgi-=20
>> bin environment variable.
> No, they are not.
> A cgi-bin environment variable is only set by a webserver when =20
> running a cgi-bin program.
> A servlet is not a cgi-bin program, and the servlet container which =20=
> runs it, does not set any "environment variables" for the servlet.
> If HttpServletRequest.getRemoteUser and =20
> HttpServletRequest.getUserPrincipal return null, it is because they =20=
> both look into the UserPrincipal object, which is probably not set, =20=
> because you have not done any authentication (yet) in your servlet =20
> container.
>
> You have just read a HTTP header, and gotten back a String as a =20
> result. That does not, for the servlet container, constitute reason =20=
> enough to take that String, consider it as a bona fide user-id, and =20=
> set it into the UserPrincipal object so that =20
> HttpServletRequest.getRemoteUser would nicely return it. Hence the =20
> nulls.
>
> So it looks like you still have some work to do.
> But that is now a question which belongs to the GlassFish forum.
>
>
> ------------------------------------------------------------ ---------
> The official User-To-User support forum of the Apache HTTP Server =20
> Project.
> See for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> " from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
--Apple-Mail-24--557968867
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
charset=iso-8859-1
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space; =
">
On Oct 30, 2009, at 12:49 PM, Andr=E9 Warnier =
wrote:
Glad to have been of =
help.
One more nitpick however, below, lest you remain partly =
confused.
Yes, indeed. I =
was confused by the "
style=3D"font-family: Times; ">Same as the value of the CGI variable =
REMOTE_USER." statement in the HttpServletRequest.getRemoteUser javadoc, =
but you have again helped explain that.
class=3D"Apple-style-span" face=3D"Times">
class=3D"Apple-style-span" face=3D"Times">Thanks =
again,
face=3D"Times">Devin
type=3D"cite">
Devin Bougie wrote:
...
With the latest =
posted configuration,
I am able to see the =
REMOTE_USER HTTP header from the backend GlassFish Web Application =
(using HttpServletRequest.getHeader("REMOTE_USER")).
OK, =
and correct.
As
you explain, =
HttpServletRequest.getRemoteUser and getUserPrincipal both return null =
because they are looking for the REMOTE_USER cgi-bin environment =
variable.
No, they are not.
A cgi-bin environment =
variable is only set by a webserver when running a cgi-bin program.
A =
servlet is not a cgi-bin program, and the servlet container which runs =
it, does not set any "environment variables" for the servlet.
If =
HttpServletRequest.getRemoteUser and HttpServletRequest.getUserPrincipal =
return null, it is because they both look into the UserPrincipal object, =
which is probably not set, because you have not done any authentication =
(yet) in your servlet container.
You have just read a HTTP =
header, and gotten back a String as a result. That does not, for =
the servlet container, constitute reason enough to take that String, =
consider it as a bona fide user-id, and set it into the UserPrincipal =
object so that HttpServletRequest.getRemoteUser would nicely return it. =
Hence the nulls.
So it looks like you still have some work to =
do.
But that is now a question which belongs to the GlassFish =
forum.
--------------------------------------------------------=
-------------
The official User-To-User support forum of the Apache =
HTTP Server Project.
See =
<URL:http://httpd.apache.org/userslist.html> for more info.
To =
unsubscribe, e-mail:
href=3D"mailto:users-unsubscribe@httpd.apache.org">users-uns ubscribe@httpd=
..apache.org
" from the digest:
href=3D"mailto:users-digest-unsubscribe@httpd.apache.org">us ers-digest-uns=
ubscribe@httpd.apache.org
For additional commands, e-mail:
href=3D"mailto:users-help@httpd.apache.org">users-help@httpd .apache.org
>
=
--Apple-Mail-24--557968867--