配置nginx https wss
来源:互联网 发布:科勒淘宝授权 编辑:程序博客网 时间:2024/06/14 18:40
1、 编辑nginx.conf文件
#server {
# listen 443 ssl;# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
include wss.conf;# 这里我们将反向代理新建一个文件引入进来
在 \nginx\conf目录下,nginx.conf 中配置wss.conf
2、 下载证书 https://www.qcloud.com/product/ssl
3、在nginx\conf目录下,新建wss.conf文件,编辑wss.conf
upstream websocket {
server cloud.xxx.net:9050;# 远程websocket服务器地址
}
upstream web{
server cloud.x'x'x.net;# 远程http接口
}
server {
listen 443;#默认https和wss协议端口
ssl on;
ssl_certificate C:\phpStudy\Apache\conf\ssl\1_cloud.xxx.net_bundle.crt;
ssl_certificate_key C:\phpStudy\Apache\conf\ssl\2_cloud.xxx.net.key;
ssl_session_timeout 5m;
ssl_session_cache shared:SSL:50m;
ssl_protocols SSLv3 SSLv2 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
underscores_in_headers on;#开启自定义头信息的下划线
#wss协议转发 小程序里面要访问的链接
location /wss {
proxy_pass http://websocket;#代理到上面的地址去
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
#https协议转发 小程序里面要访问的链接
location /{
proxy_pass http://web;#代理到原有的http的地址去
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Access-Control-Allow-Origin *;#跨域访问设置
}
}
3、启动nginx
nginx.exe
4、停止 nginx -s stop
5、注意wss.conf文件中的“ location /wss {”
在客户端访问wss时,应以wss://xxx.xxx.xxx/wss 一致。
https、wss默认都是443端口
下载证书,证书放在nginx/conf目录
- 配置nginx https wss
- https 的wss nginx配置
- nginx 配置https和wss
- nginx配置https或wss服务
- 【配置】使用nginx反向代理加密websocket (wss)
- Nginx(12):nginx配置https
- nginx 配置https server
- nginx 配置https
- Nginx 配置 https 加密
- Nginx配置https服务器
- Ubuntu nginx 配置https
- nginx https配置
- nginx配置https
- nginx 配置https
- nginx 配置HTTPS服务器
- Linux nginx配置https
- nginx 配置https 环境
- Nginx配置Https
- Ubuntu 16.04下安装64位谷歌Chrome浏览器
- css 日常总结
- OkHttp3详解
- Git 常用命令 更新与提交
- UML简介
- 配置nginx https wss
- 04:求整数的和与均值
- FFXI-darkstar源码阅读
- SSH和SSM对比总结
- 2017.09.04
- 按第一列的相同名称合并行
- py pypinyin 拼音库
- py jieba 分词库
- Java实例变量和类变量