我很享受试验Bailador一段时间了。设置和使用普通HTTP请求很容易,但我想通过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;
}
此外,Cookie还包含强制https相关内容。
我已经搜索过文档和示例,说明如何/如果支持HTTPS,但尚未成功。
那么,我可以在Bailador中通过HTTPS提供内容吗?如果是这样,怎么样?
答案 0 :(得分: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;
}
}