I'm trying to set up an Apache reverse proxy on server B for a private server A, which has three users: a1, a2, and a3. Server B utilizes a TXT map file to map all kinds of users on server B (b1,b2...) to server A (a1,a2,a3). Server A uses the header "X-GROUP" as its user name.
The current Apache configuration is as follows:
RewriteEngine On
RewriteMap groupmap txt:/etc/apache2/group_map.txt
RewriteRule .* - [E=GROUP_POLICY:${groupmap:%{LA-U:REMOTE_USER}}]
RequestHeader set X-GROUP %{GROUP_POLICY}e
RequestHeader set X-GROUP-TEST %{REMOTE_USER}e
<Location "/">
AuthType Basic
AuthName "private area"
AuthBasicProvider PAM
AuthPAMService www-data
Require valid-user
</Location>
<Location "/file">
ProxyPass http://192.168.46.1:8080
ProxyPassReverse http://192.168.46.1:8080
</Location>
As you can see, server A is host on 192.168.46.1:8080, txt map file is /etc/apache2/group_map.txt .Additionally, X-GROUP-TEST is used for test.
However, the HTTP requests received by server B contain the header X-GROUP without any assigned value,But X-GROUP-TEST is correctly set to b1, as evidenced by the packet captured using Wireshark
https://i.sstatic.net/QRPr5qnZ.png
the package is catched using wireshark.
Then I write a printenv.php
in the server B's web root directory to display all headers, it shows that that all two headers are correctly set(X-GROUP=a1 X-GROUP-TEST=b1).
https://i.sstatic.net/zj7lrt5n.png
I don't know what's wrong with my configuration and why did this happened.
Any suggestions are greatly appreciated!