websocket使用ssl 证书,开启加密服务
参考文章: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 defaultfalse. 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 证书,开启加密服务的更多相关文章
- 阿里云slb和ucloud负载均衡ulb添加ssl证书将http服务https化的配置详解
阿里云和ucloud服务器配置ssl证书将http服务https化的配置详解 项目背景: 苹果App于2017年1月1日将启用App Transport Security安全功能,即强制App通过HT ...
- SSL证书:Web加密使互联网更安全
在网络安全的圈子里,我们都会隔三差五的听到某某公司遭受恶意软件攻击.或大量的隐私信息被泄露等等事件,此类安全事件往往都有影响范围广.涉及用户众多等特点.不免让人质疑联网的世界越来越危险.然而,在安全专 ...
- 免费获取SSL证书/一键安装SSL证书/https加密
因为我用的是恒创的香港服务器 虽然价格相较于大促的阿里云贵一些,但是有一个有点不用备案... 安装步骤: 1.登录云主机控制面板, 在 其他管理 中找到并进入 SSL证书 设置. 注意:如拥有多个域名 ...
- nginx配置SSL证书实现https服务
在前面一篇文章中,使用openssl生成了免费证书 后,我们现在使用该证书来实现我们本地node服务的https服务需求.假如我现在node基本架构如下: |----项目 | |--- static ...
- 免费SSL证书PK付费SSL证书 花落谁家
3月17日和18日,Google Chrome 57.0.2987.110与Mozilla Firefox 52.0.1分别上线,而这两款浏览器都出现了一个共同点:打压HTTP协议.在Firefox ...
- 免费SSL&付费SSL证书,该如何选择?
近年来Google.Apple.百度等公司不断推动 HTTPS 的普及,SSL 证书作为 HTTPS 安全协议的必备配置,自然也成为了网站.App 开发者最重要部署项目之一. 又拍云于 2016 年联 ...
- HTTPS那些事(二)SSL证书(转载)
原创地址:http://www.guokr.com/post/116169/ 从第一部分HTTP工作原理中,我们可以了解到HTTPS核心的一个部分是数据传输之前的握手,握手过程中确定了数据加密的密 ...
- HTTPS那些事(二)SSL证书
转自:http://www.guokr.com/post/116169/ 从第一部分HTTPS原理中, 我们可以了解到HTTPS核心的一个部分是数据传输之前的握手,握手过程中确定了数据加密的密码.在握 ...
- (二)、SSL证书
从第一部分HTTPS原理中,我们可以了解到HTTPS核心的一个部分是数据传输之前的握手,握手过程中确定了数据加密的密码.在握手过程中,网站会向浏览器发送SSL证书,SSL证书和我们日常用的身份证类似, ...
随机推荐
- oracle 修改数据 保险方法
oracle 中修改比较安全的方法:(pl/sql) 第一种方法: select * from temp where id=9 for update; 第二种方法: select t.*,rowid ...
- Codeforces Round #241 (Div. 2) B dp
B. Art Union time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- iOS 初始化(init、initWithNibName、initWithCoder、initWithFrame)
很多朋友如果是初学iOS开发,可能会被其中的几个加载方法给搞得晕头转向的,但是这几个方法又是作为iOS程序员必须要我们掌握的方法,下面我将对这几个方法做一下分析和对比,看看能不能增加大家对几个方法的理 ...
- Nginx + tomcat 实现简单集群(基于反向代理方式)
一.安装 nginx 1. nginx依赖以下一些软件库,在安装之前请确保安装了这些软件库,它们包括:gcc,openssl,zlib,pcre(可通过rpm -q命令查询是否已安装) 可通过命令 r ...
- Cover
[题目描述] 有 N 个时间段,某个时间段可能包含其它时间段. 请找出能包含其它时间段最多的那个段,并计算出它包括的其它时间段有多少? [数据范围] 1 <= N <= 25,000 1 ...
- BZOJ1709超级弹珠
1709: [Usaco2007 Oct]Super Paintball超级弹珠 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 352 Solved: ...
- Request.Form to JSON
原文发布时间为:2012-03-21 -- 来源于本人的百度文章 [由搬家工具导入] NameValueCollection nvc =newNameValueCollection(Request.F ...
- 拖动层 拖动div 封装js 貌似不兼容FF,郁闷
原文发布时间为:2009-12-02 -- 来源于本人的百度文章 [由搬家工具导入] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tran ...
- python --- comment
single line comment : multiple line comment :
- Codeforces 898 C.Phone Numbers-STL(map+set+vector)
C. Phone Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...