logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Environment variable in http.conf
Author
17132



Joined: 03 Dec 2010
Posts: 1

PostPosted: Fri 03 Dec '10 15:07    Post subject: Environment variable in http.conf Reply with quote

Hello,

I've just recompiled a apache 2.2.17 on linux with all modules in shared. I'm trying to add headers containing apache "environment variables" like SERVER_NAME, HTTP_USER_AGENT with mod_headers.
I always get null in my headers.
The response from server contains the header but I'm unable to put inside any env variables
The only thing that works is the %D and %t for time.

I'm probably missing something but I can not figure what I'm doing wrong.
Here is an extract of th httpd.conf

LoadModule env_module modules/env_headers.so
LoadModule headers_module modules/mode_headers.so
LoadModule ident_module modules/mode_ident.so
LoadModule unique_id_module modules/mode_unique_id.so
LoadModule setenvif_module modules/mode_setenvif.so
LoadModule rewrite_module modules/mode_rewrite.so


ServerName Server
Listen 8080

Header add TOTO "%D %t %{SERVER_NAME}e"

NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot /usr/local/apache/htdocs"
ServerName Server

Header add TUTU "%D %t %{SERVER_NAME}e"
</VirtualHost>


Thanks in advance for your help
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Mon 24 Jan '11 18:11    Post subject: Reply with quote

There is a way, but you have edit your apache2ctl / apachectl (name depends on your distro)

add the line
Code:

export HOSTNAME=`hostname`


In httpd.conf add PassEnv HOSTNAME and than Header add X-Server-Name "%{HOSTNAME}e"

Code:

PassEnv HOSTNAME
Header add X-Server-Name "%{HOSTNAME}e"



Also if you need the vhost name

in the vhost (has to be done for each vhost
Code:

SetEnv vhostname vhost_name
Header add X-Server-Name %{vhostname}e
Back to top


Reply to topic   Topic: Environment variable in http.conf View previous topic :: View next topic
Post new topic   Forum Index -> Apache