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证书和我们日常用的身份证类似, ...
随机推荐
- php中memcache扩展及memcached扩展的区别
1.目前大多数php环境里使用的都是不带d的memcache版本,这个版本出的比较早,是一个原生版本,完全在php框架内开发的.与之对应的带d的memcached是建立在libmemcached的基础 ...
- Codeforces Round #281 (Div. 2) A 模拟
A. Vasya and Football time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Vue中slot内容分发
<slot>元素是一个内容分发API,使用多个内容插槽时可指定name属性 <!DOCTYPE html> <html> <head> <meta ...
- 关于fixed定位的一些错误看法纠正
之前由于一些误导,一直感觉fixed这个定位在ie8下面是会出现兼容问题的,今天发现这个想法太绝对了,它只是在ie7 8 的怪异模式下面会出现兼容问题 解决这个问题可以通过用absolute来模拟fi ...
- uoj 131/bzoj 4199 [NOI2015]品酒大会 后缀树+树d
题目大意 见uoj131 分析 题目的提示还是很明显的 \(r\)相似就就代表了\(0...r-1\)相似 建出后缀树我们能dfs算出答案 再后缀和更新一下即可 注意 细节挺多的,但数据很良心 不然我 ...
- 【HDOJ5534】Partial Tree(树,背包DP)
题意:有一棵n个点的形态不定的树,每个度为i的节点会使树的权值增加f[i],求树的最大权值 n<=2015,0<=f[i]<=1e4 思路:对不起队友,我再强一点就能赛中出这题了 显 ...
- 【CF1068A】Birthday(签到)
题意:有N种棋子,M个人,已有K种收藏,要求最小的每个人送的棋子数使得最坏情况下至少有L种新的收藏,无解输出-1 N,M,K,L<=1e18 思路: #include<cstdio> ...
- 排名次SQL语句【名次可重复时】
原文发布时间为:2008-10-26 -- 来源于本人的百度文章 [由搬家工具导入] 功能实现 名次可重复时,比如第一名有两个。。。 select *,(select count(distin ...
- 例说linux内核与应用数据通信系列【转】
转自:http://blog.csdn.net/shallnet/article/details/47865169 版权声明:本文为博主原创文章,未经博主允许不得转载.如果您觉得文章对您有用,请点击文 ...
- 深入代码详谈irqbalance【转】
转自:http://blog.csdn.net/whrszzc/article/details/50533866 版权声明:本文为博主原创文章,未经博主允许不得转载. 深入代码详谈irqbalance ...