参考文章:https://fzambia.gitbooks.io/centrifugal/content/deploy/certificates.html

TLS certificates

TLS/SSL layer is very important not only for securing your connections but also to increase a chance to establish Websocket connection. In most situations you will put TLS termination task on your reverse proxy/load balancing software such as Nginx.

There are situations though when you want to serve secure connections by Centrifugo itself.

There are two ways to do this: using TLS certificate cert and key files that you've got from your CA provider or using automatic certificate handling via ACME provider (only Let's Encrypt at this moment).

Using crt and key files

In first way you already have cert and key files. For development you can create self-signed certificate - see this instruction as example.

Then to start Centrifugo use the following command:

./centrifugo --config=config.json --ssl --ssl_key=server.key --ssl_cert=server.crt

Or just use configuration file:

{
...
"ssl": true,
"ssl_key": "server.key",
"ssl_cert": "server.crt"
}

And run:

./centrifugo --config=config.json

Automatic certificates

For automatic certificates from Let's Encrypt add into configuration file:

{
...
"ssl_autocert": true,
"ssl_autocert_host_whitelist": "www.example.com",
"ssl_autocert_cache_dir": "/tmp/certs",
"ssl_autocert_email": "user@example.com"
}

ssl_autocert says Centrifugo that you want automatic certificate handling using ACME provider.

ssl_autocert_host_whitelist is a string with your app domain address. This can be comma-separated list. It's optional but recommended for extra security.

+

ssl_autocert_cache_dir is a path to a folder to cache issued certificate files. This is optional but will increase performance.

ssl_autocert_email is optional - it's an email address ACME provider will send notifications about problems with your certificates.

When configured correctly and your domain is valid (localhost will not work) - certificates will be retrieved on first request to Centrifugo.

Also Let's Encrypt certificates will be automatically renewed.

There are tho options (new in v1.6.5) that allow Centrifugo to support TLS client connections from older browsers such as Chrome 49 on Windows XP and IE8 on XP:

  • ssl_autocert_force_rsa - this is a boolean option, by default false. When enabled it forces autocert manager generate certificates with 2048-bit RSA keys.
  • ssl_autocert_server_name - string option, allows to set server name for client handshake hello. This can be useful to deal with old browsers without SNI support - see comment

实例:

阿里云下载域名的证书

上传到服务器  /home/websocket_cert/1522*******822.key  ,   /home/websocket_cert/1522*****4822.pem

cat /data/centrifugo/config_ssl.json 

 "log_level": "debug",
"connection_lifetime": ,
"admin_password": "admin",
"admin_secret": "admin_secret",
"recover": true,
"admin":true,
"web":true,
"anonymous": true,
"ssl": true,
"ssl_key": "/home/websocket_cert/152******4822.key",
"ssl_cert": "/home/websocket_cert/152******4822.pem"
}

启动服务:

/data/centrifugo/centrifugo -d -c /data/centrifugo/config_ssl.json -p **  --log_file /data/centrifugo/error_ssl.log --log_level debug --web &

若是阿里云服务器 请在安全组开启 相应端口允许 。

实例访问效果:

websocket使用ssl 证书,开启加密服务的更多相关文章

  1. 阿里云slb和ucloud负载均衡ulb添加ssl证书将http服务https化的配置详解

    阿里云和ucloud服务器配置ssl证书将http服务https化的配置详解 项目背景: 苹果App于2017年1月1日将启用App Transport Security安全功能,即强制App通过HT ...

  2. SSL证书:Web加密使互联网更安全

    在网络安全的圈子里,我们都会隔三差五的听到某某公司遭受恶意软件攻击.或大量的隐私信息被泄露等等事件,此类安全事件往往都有影响范围广.涉及用户众多等特点.不免让人质疑联网的世界越来越危险.然而,在安全专 ...

  3. 免费获取SSL证书/一键安装SSL证书/https加密

    因为我用的是恒创的香港服务器 虽然价格相较于大促的阿里云贵一些,但是有一个有点不用备案... 安装步骤: 1.登录云主机控制面板, 在 其他管理 中找到并进入 SSL证书 设置. 注意:如拥有多个域名 ...

  4. nginx配置SSL证书实现https服务

    在前面一篇文章中,使用openssl生成了免费证书 后,我们现在使用该证书来实现我们本地node服务的https服务需求.假如我现在node基本架构如下: |----项目 | |--- static ...

  5. 免费SSL证书PK付费SSL证书 花落谁家

    3月17日和18日,Google Chrome 57.0.2987.110与Mozilla Firefox 52.0.1分别上线,而这两款浏览器都出现了一个共同点:打压HTTP协议.在Firefox ...

  6. 免费SSL&付费SSL证书,该如何选择?

    近年来Google.Apple.百度等公司不断推动 HTTPS 的普及,SSL 证书作为 HTTPS 安全协议的必备配置,自然也成为了网站.App 开发者最重要部署项目之一. 又拍云于 2016 年联 ...

  7. HTTPS那些事(二)SSL证书(转载)

    原创地址:http://www.guokr.com/post/116169/   从第一部分HTTP工作原理中,我们可以了解到HTTPS核心的一个部分是数据传输之前的握手,握手过程中确定了数据加密的密 ...

  8. HTTPS那些事(二)SSL证书

    转自:http://www.guokr.com/post/116169/ 从第一部分HTTPS原理中, 我们可以了解到HTTPS核心的一个部分是数据传输之前的握手,握手过程中确定了数据加密的密码.在握 ...

  9. (二)、SSL证书

    从第一部分HTTPS原理中,我们可以了解到HTTPS核心的一个部分是数据传输之前的握手,握手过程中确定了数据加密的密码.在握手过程中,网站会向浏览器发送SSL证书,SSL证书和我们日常用的身份证类似, ...

随机推荐

  1. [luoguP2224] [HNOI2001]产品加工(背包DP)

    传送门 f[i][j]表示第一个机器耗时j,第二个机器耗时f[i][j] 第一维可以滚掉 #include <cstdio> #include <cstring> #inclu ...

  2. bzoj1093【ZJOI2007】最大半联通子图

    题意:http://www.lydsy.com/JudgeOnline/problem.php?id=1093 sol  :一开始理解错题意了QAQ,还莫名其妙写挂了QAQ,调了半天 首先显然一个强联 ...

  3. bzoj 2741 [FOTILE模拟赛] L

    Description 多个询问l,r,求所有子区间异或和中最大是多少 强制在线 Solution 分块+可持久化trie 1.对于每块的左端点L,预处理出L到任意一个i,[L,j] 间所有子区间异或 ...

  4. Mysql 取整的方法

    .CEIL() 向上取整 SELECT CEIL(/); .FLOOR() 向下取整 SELECT FLOOR( .ROUND() 四舍五入 SELECT ROUND(

  5. 【HDOJ5975】Aninteresting game(BIT原理)

    题意:给定n个区间,第i个区间的范围是[i-lowbit(i)+1,i].一共有q组询问,询问有两种: 1 x y:询问sigma lowbit(i) (x<=i<=y) 2.x:询问有几 ...

  6. 容易混淆的某些Math方法说明

    1. Math.round 返回最接近的整数值,实际上就是我们说的对小数进行四舍五入. /** * 返回最接近参数的long */ static long round(double a) /** * ...

  7. FTK应用程序编程接口(API)手册-1【转】

    转自:http://blog.csdn.net/absurd/article/details/6702047 框架函数 框架函数支撑FTK的主体,它负责初始化应用程序,启动主循环和退出主循环.它对任何 ...

  8. 打造好用的编辑终端环境yakuake

    我喜欢使用vim,由于不喜欢不够纯粹的东西,所以将伪终端打造的和真终端几乎一样,我的yakuake全屏是真的全屏,你也想这样,跟我来吧. 一.修改yakuake的皮肤文件,在/usr/share/ya ...

  9. C#性能优化篇 - 基于索引器封装EPList

    using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Sy ...

  10. Django之model F/Q以及多对多操作

    model之F/Q操作 F操作,使用查询条件的值 打个比方吧,有一张表,保存着公司员工的工资,公司普涨工资,如何在model中操作,这就用到了F,首先需要导入此模块: from django.db.m ...