2017-07-18 46 views
4

我已經享受了一段時間Bailador的實驗。設置和使用普通的HTTP請求很容易,但我想通過HTTPS提供內容。如何配置Bailador通過TLS(HTTPS)提供內容?

一些Request方法似乎暗示HTTPS請求是可能的:

method scheme  { $.env<p6w.url-scheme> || 'http' } 
method secure  { so self.scheme eq 'https' } 

和頭方法:

method headers() { 
    return %!headers if %!headers; 
    for $.env.keys.grep(rx:i/^[HTTP||CONTENT]/) -> $key { 
     my $field = S:i/HTTPS?_// given $key; 
     %!headers{$field.uc} = $.env{$key}; 
    } 
    return %!headers; 
} 

加上餅乾紛紛發力-HTTPS在他們相關的東西,以及。

我已經搜索了文檔和示例,指出如何支持HTTPS,但尚未成功。

那麼,我可以通過HTTPS在Bailador上提供內容嗎?如果是這樣,怎麼樣?

回答

7

我討厭成爲「那個沒有回答你的問題但把你送到別的地方的人」,但我從來沒有在應用程序中使用SSL。讓Bailador只聽本地主機上的端口5284。然後設置在nginx的反向代理(包括一些letsencrypt東西):

server { 
    listen *:443; 
    server_name example.com; 

    ssl on; 
    ssl_certificate  /etc/letsencrypt/certs/example.com/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/certs/example.com/privkey.pem; 

    # Optional: only uncomment once you are sure your SSL works! 
    #add_header Strict-Transport-Security "max-age=15768000"; 

    location /.well-known/acme-challenge/ { alias /var/www/letsencrypt/; } 
    location/{ 
     proxy_pass http://127.0.0.1:5284/; 
     proxy_set_header Host $host; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header X-Forwarded-Port 443; 
     proxy_set_header X-Forwarded-Host $host; 

     # re-write redirects to http as to https 
     proxy_redirect http:// https://; 
    } 
} 

獎勵積分,重定向所有的HTTP訪問到https:

server { 
    listen *:80; 
    server_name example.com; 

    location /.well-known/acme-challenge/ { alias /var/www/letsencrypt/; } 
    location/{ 
     return 301 https://$server_name$request_uri; 
    } 
} 
+0

不,這是很好的。挖掘之後,我開始懷疑某種代理將是最好的路線。 –