2017-02-13 25 views
0

在我的linode盒子上,我安裝了Let's Encrypt SSL證書並創建了一個裸機Vibe.d應用程序來測試我的SSL連接。我總是超時。下面是代碼:Vibe.d上的HTTPS

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 

和山貓提醒我有關的證書,但按「Y」後,我可以看到網站兩次。

我還可以做

lynx http://localhost 

但不

lynx http://localhost:8080 

在這一點上,我不知道如果我的代碼是錯誤的或我的設置是錯誤的。

我的UFW防火牆允許從任何地方使用HTTPS。

回答

2

我會使用nginx作爲您的vibe-d應用程序的代理,這是更好的方法,然後嘗試使用ssl使用vibed。

但是你的設置似乎很奇怪。您正在8080上收聽,所以不應該可以通過 www.findyourtutor.infofindyourtutor.info來訪問您的網站,而無需指定端口,所以我想還有其他一些網絡服務器正在播放。如果你想使用https,你應該試着聽443。或者你有沒有準備好一些代理?

+0

感謝您的回答,@ Kozzi11。是的,它似乎很奇怪,但它以某種方式起作用。我會嘗試你的建議。 –

+0

Hi @ Kozzi11,我發現我的程序在發出ps aux後有多個實例,其中一個在80端口監聽!所以我重新啓動了我的linode,現在一切都更清晰了。 –