S. *_*ano 5 https perl6 bailador
我很享受试验Bailador一段时间了.设置和使用普通HTTP请求很容易,但我想通过HTTPS提供内容.
一些Request方法似乎暗示HTTPS请求是可能的:
method scheme { $.env<p6w.url-scheme> || 'http' }
method secure { so self.scheme eq 'https' }
Run Code Online (Sandbox Code Playgroud)
和标题方法:
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;
}
Run Code Online (Sandbox Code Playgroud)
此外,cookie还包含force-https相关内容.
我已经搜索了文档和示例,指出如何/如果支持HTTPS,但尚未成功.
那么,我可以在Bailador中通过HTTPS提供内容吗?如果是这样,怎么样?
我讨厌成为"那个不回答你的问题而是把你送到其他地方的人",但我从不在应用程序中使用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://;
}
}
Run Code Online (Sandbox Code Playgroud)
对于奖励积分,将所有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;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
179 次 |
| 最近记录: |