| 
 
 
 | 
| Keep Server Online 
 If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
 
 or
 
 
   
 A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
 
 Thank You! Steffen
 
 Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
 |  | 
 | 
| | 
| | 
|  Topic: how to enable RequestHeader? |  |  
| Author |  |  
| scwindy 
 
 
 Joined: 18 Oct 2011
 Posts: 3
 
 
 | 
|  Posted: Tue 18 Oct '11 8:01    Post subject: how to enable RequestHeader? |   |  
| 
 |  
| hello, everyone. I got a problem when I use mod_headers with apache. 
 my apache was configure as "./configure --enable-so --enable-rewrite --enable-proxy --enable-headers" to enable headers, and my server is config with:
 Listen 10080
 
 NameVirtualHost *:10080
 
 <VirtualHost *:10080>
 ServerAdmin webmaster@localhost
 DocumentRoot "/usr/local/rzrq_proxy"
 
 <Directory />
 Options FollowSymLinks
 AllowOverride None
 </Directory>
 
 <Directory /usr/local/rzrq_proxy>
 Options Indexes FollowSymLinks MultiViews
 AllowOverride None
 Order allow,deny
 Allow from all
 </Directory>
 
 ServerName rzrq_proxy
 ErrorLog "/usr/local/apache2/logs/rzrq_proxy_error_log"
 CustomLog "/usr/local/apache2/logs/rzrq_proxy_access_log" common
 
 RequestHeader set USER  "TestUser"
 Header set REMOTE_USER "remote-user"
 
 #ProxyRequests Off
 #ProxyVia On
 
 #<Proxy *>
 #Order deny,allow
 #Allow from all
 #</Proxy>
 
 #ProxyPass / http://192.168.188.156:8000/
 #ProxyPassReverse / http://192.168.188.156:8000/
 </VirtualHost>
 
 when i started server and sent visit the 10080 port, the request header and reponse header is show like:
 
 REQUEST:
 GET / HTTP/1.1
 Host: 211.150.96.16:10080
 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.1
  Gecko/20110614 Firefox/3.6.18 ( .NET CLR 3.5.30729) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
 Accept-Language: zh-cn,zh;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: GB2312,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 115
 Connection: keep-alive
 Cookie: session_id_8000=4477a45072e4a91c04a35eb2c905a4fec596f109
 
 RESPONSE:
 HTTP/1.1 303 See Other
 Date: Tue, 18 Oct 2011 13:53:03 GMT
 Server: CherryPy/3.1.2
 Content-Length: 114
 Content-Type: text/html;charset=utf-8
 Location: http://211.150.96.16:10080/zh-CN/
 Set-Cookie: session_id_8000=3c1a46903da09835bad54aaf886a58becd965345; expires=Wed, 19 Oct 2011 13:53:03 GMT; Path=/
 REMOTE_USER: remote-user
 Keep-Alive: timeout=5, max=100
 Connection: Keep-Alive
 
 i think only the Header directive enabled, and  RequestHeader directive is not.
 
 how to enable RequestHeader? thank you.
 
 ps: my test envirment:
 Red Hat Enterprise Linux Server release 5.3
 Apache 2.2.21, 2.0.50
 |  |  
| Back to top |  |  
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Tue 18 Oct '11 10:15    Post subject: |   |  
| 
 |  
|  	  | Code: |  	  | RequestHeader set USER "TestUser"
 Header set REMOTE_USER "remote-user"
 
 | 
 
 I think your problem is that you override that header with the second one. AFAIK you should use append instead if set for the second header.
 |  |  
| Back to top |  |  
| scwindy 
 
 
 Joined: 18 Oct 2011
 Posts: 3
 
 
 | 
|  Posted: Tue 18 Oct '11 11:12    Post subject: |   |  
| 
 |  
|  	  | James Blond wrote: |  	  |  	  | Code: |  	  | RequestHeader set USER "TestUser"
 Header set REMOTE_USER "remote-user"
 
 | 
 
 I think your problem is that you override that header with the second one. AFAIK you should use append instead if set for the second header.
 | 
 
 I change the header "USER" by another word like "X-USER-OTHER", and can't got in the browser's debug tools like firedebug(Firefox) or httpwatch(IE) debug infomation. Is the header set by RequestHeader can't be caught by browser's debug tools? Was the header sent before or after rebuild by browser? or just the version of apache? thank you!
 |  |  
| Back to top |  |  
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Tue 18 Oct '11 13:52    Post subject: |   |  
| 
 |  
| You can't view with a normal debugger, cause it is on the server side. In a php script you can see it with 
 
  	  | Code: |  	  | echo $_SERVER["HTTP_USER"];
 
 | 
 
 in a log file you might see it with
 
 %{USER}i or %{HTTP_USER}i
 
 
 Back to your question: with your posted config it works, but the RequestHeader will not send to the client.
 |  |  
| Back to top |  |  
| scwindy 
 
 
 Joined: 18 Oct 2011
 Posts: 3
 
 
 | 
|  Posted: Thu 20 Oct '11 3:10    Post subject: |   |  
| 
 |  
|  	  | James Blond wrote: |  	  | You can't view with a normal debugger, cause it is on the server side. In a php script you can see it with 
 
  	  | Code: |  	  | echo $_SERVER["HTTP_USER"];
 
 | 
 
 in a log file you might see it with
 
 %{USER}i or %{HTTP_USER}i
 
 
 Back to your question: with your posted config it works, but the RequestHeader will not send to the client.
 | 
 
 Hi,thank you for your help. but how can i get the value of some header send by apache with RequestHeader, just like "X-REMOTE-USER"? Use php script _SERVER, i can only get some header standard like "Host". Is there any mothods?
 |  |  
| Back to top |  |  
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Thu 20 Oct '11 11:47    Post subject: |   |  
| 
 |  
| OK, within PHP you can try
 
 apache_response_headers()
 and
 apache_request_headers()
 
 works only if you run PHP as module in apache.
 |  |  
| Back to top |  |  
 
 | 
 |  | 
 |  |