我有一个 Lighttpd 服务器作为 Ruby on rails 的前端。
一些子域名(server1.domain.com
,server2.domain.com
)配置了代理。
但也有一个标准的静态 Web 服务器www.domain.com
。
它可以工作,但是没有子域的调用(domain.com
)不起作用。
我该如何为其配置 Lighttpd?
代理配置:
$HTTP["host"] =~ "www.domain." {
alias.url = ( "/system/" => "/var/www/system/" )
proxy.balance = "fair"
proxy.server = ( "" => (
( "host" => "127.0.0.1", "port" => 5750)
)
)
}
服务器1和服务器2的配置:
$HTTP["host"] =~ "server1.domain." {
alias.url = ( "/system/" => "/var/www/system/" )
proxy.balance = "fair"
proxy.server = ( "" => (
( "host" => "127.0.0.1", "port" => 7757 ) ,
( "host" => "127.0.0.1", "port" => 5222),
( "host" => "127.0.0.1", "port" => 5223)
)
)
}
$HTTP["host"] =~ "server2.domain." {
alias.url = ( "/system/" => "/var/www/system/" )
proxy.balance = "fair"
proxy.server = ( "" => (
( "host" => "127.0.0.1", "port" => 7787 ) ,
( "host" => "127.0.0.1", "port" => 5282),
( "host" => "127.0.0.1", "port" => 5283)
)
)
}
答案1
你有两个解决方案。
第一
www
如果域名为domain.com
:,则将流量重定向到:
$HTTP["host"] =~ "^domain\.com" {
url.redirect = (
"^/(.*)" => "http://www.domain.com/$1",
"" => "http://www.domain.com/"
)
}
第二个
处理和的流量www.domain.
(domain.
然后小心重复的内容)。将旧规则替换为www.domain.
:
$HTTP["host"] =~ "(^domain.)|(^www.domain.)" {
alias.url = ( "/system/" => "/var/www/system/" )
proxy.balance = "fair"
proxy.server = ( "" => (
( "host" => "127.0.0.1", "port" => 5750)
)
)
}