Lighttpd的Cloudflare http到https重定向

Lighttpd的Cloudflare http到https重定向,https,lighttpd,cloudflare,Https,Lighttpd,Cloudflare,我在我的站点上使用cloudflare,需要将默认重定向从http重定向到https。我使用没有ssl的lighttpd web服务器,我希望使用cloudflare的ssl 我找到了一篇关于Lighttpd的文章,但我现在不知道如何使其成为Lighttpd。假设您已为域名添加了.pem和.crt文件,请将以下内容添加到Lighttpd.conf文件中。这将使用mod_rewrite,因此在服务器下。不要忘记添加mod_rewrite。您的lighttpd.conf文件在server.modul

我在我的站点上使用cloudflare,需要将默认重定向从http重定向到https。我使用没有ssl的lighttpd web服务器,我希望使用cloudflare的ssl


我找到了一篇关于Lighttpd的文章,但我现在不知道如何使其成为Lighttpd。假设您已为域名添加了.pem和.crt文件,请将以下内容添加到Lighttpd.conf文件中。这将使用mod_rewrite,因此在服务器下。不要忘记添加mod_rewrite。您的lighttpd.conf文件在server.modules部分应该如下所示

server.modules = (
"mod_access",
"mod_alias",
"mod_compress",
"mod_redirect",
"mod_simple_vhost",
"mod_setenv",
    "mod_rewrite",
)
在lighttpd.conf文件的末尾,附加该文件,以便将所有HTTP链接重写为HTTPS

$HTTP["scheme"] == "http" {
$HTTP["host"] =~ ".*" {
    url.redirect = (".*" => "https://%0$0")
    }
}
或者,您可以通过转到Cloudflare域设置来强制Cloudflare SSL。 登录到您的Cloudflare帐户。在所需域下,转到Crypto,并将SSL设置更改为Full。这将强制所有连接都使用SSL