加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

如何配置Bailador通过TLS(HTTPS)提供内容?

发布时间:2020-12-16 06:28:24 所属栏目:大数据 来源:网络整理
导读:我很享受试验Bailador一段时间了.设置和使用普通HTTP请求很容易,但我想通过HTTPS提供内容. 一些Request方法似乎暗示HTTPS请求是可能的: method scheme { $.envp6w.url-scheme || 'http' }method secure { so self.scheme eq 'https' } 和标题方法: method
我很享受试验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还包含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://;
    }
}

对于奖励积分,将所有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;
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读