Link to home
Start Free TrialLog in
Avatar of systemsautomation
systemsautomationFlag for Pakistan

asked on

Error with Lighttpd

Hello

I am adding the following lines in lighttpd.conf

server.modules += ( "mod_setenv" )
setenv.add-request-header = ( "X-Proxy" => server.name )

But when reloading getting following error:

Reloading web server configuration: lighttpdUndefined config variable: server.name

But when change it to following it works fine

server.modules += ( "mod_setenv" )
setenv.add-response-header = ( "X-Proxy" => "www-02" )

It is not getting  server.name. I have got this example from http://www.cyberciti.biz/faq/mod_setenv-lighttpd-send-custom-headers/ and trying to implement at my place but failing.

Please help

ASKER CERTIFIED SOLUTION
Avatar of trencH87
trencH87
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of systemsautomation

ASKER

Thanks for the answer

Actually I want to put the client's IP address to this variable. Can you please guide me ?
In correctly configured PHP on a LAMP stack you can usually find the client's IP address here:

$_SERVER["REMOTE_ADDR"]    

It is a string that looks something like this:

98.169.58.122

This is not 100% foolproof, but I have found it to be pretty reliable.  HTH, ~Ray
Read the question first, Ray ;o)

To the last question: Change the server.name to server.bind in both lines: "X-Proxy" => server.name becomes "X-Proxy" => server.bind and server.name = "servername" becomes server.bind = "IP-address"

Best of luck!

Chris
Well, it was posted in the PHP zone, and the Asker wrote, "Actually I want to put the client's IP address to this variable."  Guess you can't please everyone!
Hehe, true true.
Hello trencH87

Your solution is quite closer and may be perfect as per this question's scope.

But the task I want to do ultimately is that I want to pass the User's IP (not server's) to a new CGI Variable. I have opened a new question for this and will be really thankful If you can help:

https://www.experts-exchange.com/questions/26495831/Lighttpd-HTTP-Headers.html