tags:

views:

213

answers:

3

I am trying to configure my lighttpd server to use a fastcgi module. The recipe I am following ( blindly ) calls for the following line in lighttpd.conf

$HTTP["host"] =~ "(^|\.)example\.com$" {

I am running on a virtual private server, and I do not have a domain name, just an IP. So I assume that I have to replace the domain name with my IP - let's say 100.101.102.103

This does not work

$HTTP["host"] =~ "(^|\.)100\.101\.102\.103$" {

Neither does several variations.

A: 

Do a lookup on your IP address, is there really no DNS name for it? They sually provide a subdomain at the very least.

Lastly, you can just put "*" and it will respond to everything.

Are you using fastcgi? it really makes a difference.

avirtuos
$HTTP["host"] =~ "*" { - this gives me a parser error.
ravenspoint
Did you try the reverse lookup i mentioned?
avirtuos
avirtuos
Unfortunately, I do want to redirect URLs.Reverse lookup just gives me the block of IP addresses that the VPS supplier has been allocated.
ravenspoint
so how would you access your site? what is the http://....... string you would use? Is it just the IP?
avirtuos
According to the documentation from lighttpd you do not need to use the HTTP["host"] unless you want to redirect urls for specific domains. If you are hosting just one domain you can use the following:url.rewrite-once = ( "^/id/([0-9]+)$" => "/index.php?id=$1")from this site:http://redmine.lighttpd.net/wiki/1/Docs:ModRewrite
avirtuos
@avirtuos Yes, you just use the IP. For example http://100.101.102.103:8000/index.html
ravenspoint
A: 

I found that this works:

$SERVER["socket"] == "0.0.0.0:8000" {
ravenspoint
A: 

You can determine what the value of $HTTP["host"] is for any given request by looking in lighttpd's access log (it's the second entry on a standard log line; it'll show as "-" if the request didn't specify one).

If the log shows you have a fixed IP address, this is a much cleaner test for it:

$HTTP["host"] == "100.101.102.103" {

(though the regular expression you were using should have worked).

What's probably causing confusion here however is the fact that $HTTP["host"] is set to the value of the "Host:" header in the incoming request so it's completely under the control of the client (browser, script, whatever) that's making the request. Knowing what the URL is you are testing with would clarify things a lot.

Perry