问题
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