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证书和我们日常用的身份证类似, ...
随机推荐
- Rust学习资源和路线
Rust学习资源和路线 来源 https://rust-lang-cn.org/article/23 学习资源 The Rust Programming Language 堪称Rust的"T ...
- BZOJ3720 Gty的妹子树 【树分块】
题目 我曾在弦歌之中听过你, 檀板声碎,半出折子戏. 舞榭歌台被风吹去, 岁月深处尚有余音一缕-- Gty神(xian)犇(chong)从来不缺妹子-- 他来到了一棵妹子树下,发现每个妹子有一个美丽度 ...
- BZOJ2393 & 1853 [Scoi2010]幸运数字 【搜索 + 容斥】
题目 在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的"幸运号码"是十进制表示中只包含数字6和8的那些号码,比如68,666,888都是" ...
- dockerfile 镜像构建
1.镜像的构建有手动与自动方式,这里我们介绍自动化的构建方式 ,dockerfile常用指令如下 2.构建指令build Usage: docker image build [OPTIONS] PAT ...
- CodeForces 605 E. Intergalaxy Trips
E. Intergalaxy Trips time limit per test:2 seconds memory limit per test:256 megabytes input:standar ...
- 洛谷P1966 火柴排队[NOIP提高组2013]
我确信我应该是做过这道题……就当再写一遍好了. 贪心思想,一番证明得出a和b数组中最小对最小,次小对次小……时解最优.那么先处理出a,b之间的对应关系,然后按照该关系求a或者b的逆序对数量就是答案 / ...
- .net web api返回结果为json
web api写api接口时默认返回的是把你的对象序列化后以XML形式返回,那么怎样才能让其返回为json呢,下面为大家介绍几种不错的方法 web api写api接口时默认返回的是把你的对象序列化后以 ...
- function in Postgres
CREATE or REPLACE FUNCTION fn_attr_category() RETURNS void AS $BODY$ declare v_tmp_rec record; begin ...
- 网站优化—MySQL优化
MySQL优化 简介 由于页面静态化技术可以实现对动态数据的缓存,但是有的时候还是需要去请求数据库.所以对数据库的优化也是不可缺少的. 优化思路 设计:存储引擎,字段,范式 自身:索引,自身的缓存 架 ...
- 洛谷——P2626 斐波那契数列(升级版)
P2626 斐波那契数列(升级版) 题目背景 大家都知道,斐波那契数列是满足如下性质的一个数列: • f(1) = 1 • f(2) = 1 • f(n) = f(n-1) + f(n-2) (n ≥ ...