lighttpd redirect from custom HTTP port 81 to HTTPS port 443

天大地大妈咪最大 提交于 2020-06-01 05:26:29

问题


I have the following configuration

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

As far as i see: %0 expands to serverip:81. So i need to get rid of :81 from %0. How?

But it leads to the redirection from HTTP port 81 to https://serverip:81 and then fails with SSL_ERROR_SYSCALL.

Answer from https://stackoverflow.com/a/62099076/3743145:

 * 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.


回答1:


Solved.

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


来源:https://stackoverflow.com/questions/62109311/lighttpd-redirect-from-custom-http-port-81-to-https-port-443

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!