Vibe.d上的HTTPS

时间:2017-02-13 16:59:09

标签: ssl https d vibed

在我的linode盒子上,我安装了Let的加密SSL证书,并创建了一个简单的Vibe.d应用程序来测试我的SSL连接。我总是超时。这是代码:

import vibe.vibe;

void main()
{
        auto settings = new HTTPServerSettings;
        settings.port = 8080;
        settings.bindAddresses = ["::1", "127.0.0.1","50.116.15.145"];
        settings.tlsContext = createTLSContext(TLSContextKind.server);
        settings.tlsContext.useCertificateChainFile("/etc/letsencrypt/live/findyourtutor.info/cert.pem");
        settings.tlsContext.usePrivateKeyFile("/etc/letsencrypt/live/findyourtutor.info/privkey.pem");
        listenHTTP(settings, &hello);

        logInfo("Please open 'http://www.findyourtutor.info' in your browser.");
        runApplication();
}

void hello(HTTPServerRequest req, HTTPServerResponse res)
{
        res.writeBody("Hello, World!");
}

如果我只是访问

www.findyourtutor.info or
findyourtutor.info

我可以很好地查看它们。

但如果我访问https://findyourtutor.info,我就会超时。

我也在

超时
https://findyourtutor.info:8080
https://www.findyourtutor.info
https://www.findyourtutor.info:8080

在linode登录时,我可以

lynx https://localhost:8080

并且lynx警告我有关证书的信息但我可以在按下' y'之后看到该网站。两次。

我也可以

lynx http://localhost

但不是

lynx http://localhost:8080

此时我不知道我的代码是否有问题或者我的设置是否有问题。

我的UFW防火墙允许从任何地方使用HTTPS。

1 个答案:

答案 0 :(得分:2)

我会使用nginx作为你的vibe-d app的代理,这比使用ssl的vibed更好。

但你的设置看起来真的很奇怪。您正在收听8080,因此无法访问您的网站 www.findyourtutor.infofindyourtutor.info没有以某种方式指定端口,所以我猜有一些其他的Web服务器在起作用。如果您想使用443,请尝试聆听https。或者你已经有了代理吗?