lighttpd从自定义HTTP端口81重定向到HTTPS端口443

lighttpd从自定义HTTP端口81重定向到HTTPS端口443,https,lighttpd,Https,Lighttpd,我有以下配置 $SERVER["socket"] == ":81" { #$HTTP["scheme"] == "http" { $HTTP["host"] =~ ".*" { url.redirect = (".*" => "https://%0$0") } } 据我所知:%0扩展到serverip:81。 所以我需要从%0中去掉:81。怎么做? 但它会导致从HTTP端口81重定向到,然后失败,并导致SSL\u ERROR\u SYSCALL 答复来自:

我有以下配置

$SERVER["socket"] == ":81" {
#$HTTP["scheme"] == "http" {
    $HTTP["host"] =~ ".*" {
        url.redirect = (".*" => "https://%0$0")
    }
}
据我所知:
%0
扩展到
serverip:81
所以我需要从
%0
中去掉
:81
。怎么做?

但它会导致从HTTP端口81重定向到,然后失败,并导致
SSL\u ERROR\u SYSCALL

答复来自:

错误是SSL\u error\u SYSCALL,这与证书验证无关。事实上,仔细看看您正在做什么,就会发现您正在从端口81上的纯HTTP重定向到同一端口上的HTTPS

解决了

$HTTP["scheme"] == "http" {
    $HTTP["host"] =~ "(.*)(:[0-9]+|)$" {  ## %1 contains hostname without port
        url.redirect = (".*" => "https://%1$0")
    }
}
$HTTP["scheme"] == "http" {
    $HTTP["host"] =~ "(.*)(:[0-9]+|)$" {  ## %1 contains hostname without port
        url.redirect = (".*" => "https://%1$0")
    }
}