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

lighttpd redirect from custom HTTP port 81 to HTTPS port 443

我有以下配置

$SERVER["socket"] == ":81" {
#$HTTP["scheme"] == "http" {
    $HTTP["host"] =~ ".*" {
        url.redirect = (".*" => "https://%0[=10=]")
    }
}

据我所知:%0 扩展为 serverip:81所以我需要从 %0 中删除 :81。怎么样?

但它导致从 HTTP 端口 81 重定向到 https://serverip:81,然后失败 SSL_ERROR_SYSCALL

来自的回答:

 * LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 192.168.144.1:81

The error is SSL_ERROR_SYSCALL and this has nothing to do with certificate validation. In fact, a closer look at what you are doing shows that you are redirecting from plain HTTP on port 81 to HTTPS on the same port.

已解决。

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