Lighttpd

Lighttpd 域重定向

  • September 22, 2012

我想在 HTTP/HTTPS 上重定向域:

http://old.com -> https://new.com
https://old.com -> https://new.com

我必須為舊域指定 SSL 密鑰/證書,但我不確定我必須在哪裡放置這些指令:

$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/pki/tls/private/new.com.pem"
ssl.ca-file = "/etc/pki/tls/certs/new.com.crt"
}

$SERVER["socket"] == ":80" {
 $HTTP["host"] =~ "old.com|new.com" {
   url.redirect = ( "^/(.*)" => "https://new.com:443/$1" )
 }
}

我試圖添加下面的程式碼,但 Lighttpd 報告配置錯誤:

$SERVER["socket"] == ":443" {
$HTTP["host"] =~ "old.com" {
url.redirect = ( "^/(.*)" => "https://new.com:443/$1" )
  }
ssl.engine = "enable"
ssl.pemfile = "/etc/pki/tls/private/old.com.pem"
ssl.ca-file = "/etc/pki/tls/certs/old.com.crt"

}

你不能那樣做。

每個埠只能有一個證書。

可能的解決方案是:

  1. 您獲得另一個 IP 地址並在此處指定舊證書。
  2. 您將獲得一個多域證書(對舊域名和新域名均有效)。

引用自:https://serverfault.com/questions/430885