首页 > 系统相关 >nginx反向代理websocket,ws转wss

nginx反向代理websocket,ws转wss

时间:2022-12-02 22:24:43浏览次数:35  
标签:set websocket header Cache add nginx wss proxy

记录一下nginx规则



location ^~ /echargenet-admin # 本地代理目录
{
    proxy_pass http://127.0.0.1:8080/xxx; # websocket地址
    proxy_set_header Host $host; # 发送host
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_read_timeout 1800s; # 读取超时时间
    proxy_send_timeout 1800s; # 发送超时时间
    proxy_set_header X-NginX-Proxy true;
    proxy_http_version 1.1;
    proxy_connect_timeout 600s; # 连接超时时间
    add_header X-Cache $upstream_cache_status;
    proxy_set_header Connection "upgrade";
    #Set Nginx Cache
    
    
    set $static_fileP7OoskYJ 0;
    if ( $uri ~* "\.(gif|png|jpg|css|js|woff|woff2)$" )
    {
    	set $static_fileP7OoskYJ 1;
    	expires 12h;
        }
    if ( $static_fileP7OoskYJ = 0 )
    {
    add_header Cache-Control no-cache;
    }
}


标签:set,websocket,header,Cache,add,nginx,wss,proxy
From: https://www.cnblogs.com/death-satan/p/nginx_ws_to_wss.html

相关文章

  • 记一次cenos7安装nginx
    安装依赖yum-yinstallgccgcc-c++makelibtoolzlibzlib-developensslopenssl-develpcrepcre-devel 下载Nginx安装包wget-chttps://nginx.or......
  • Nginx系列---【如何隐藏响应头中nginx的版本信息?】
    隐藏响应头中nginx的版本信息1.问题描述在生产环境中,如果让别人知道你的nginx版本号,刚好这个版本的nginx有漏洞,就容易被人利用这个漏洞攻击你的服务。  2.解决方案......
  • webSocket基本使用
    //创建ws实例,建立连接(ws://121.40.165.18.8800有广告)    varws=newWebSocket('wss://javascript.info/article/websocket/demo/hello')    //......
  • mac安装nginx
    homebrew安装Nginx推荐Mac电脑上内置homebrew工具安装。安装Nginx:brewinstallnginx卸载Nginx:brewuninstallnginxHomebrewHomebrew是一款MacOS平台下的......
  • nginx 命令
    Nginx在windows下常用命令:启动:直接点击Nginx目录下的nginx.exe或者cmd运行startnginx关闭nginx-sstop或者nginx-squitstop表示立即停止nginx,不保存相关信息q......
  • windos 2008 r2 安装nginx
    NGINX安装一、下载相关文件1、nginx地址:http://nginx.org/en/download.html  2、WindowsServiceWrapper地址:http://repo.jenkins-ci.org/releases/com/sun......
  • 网站搭建过程-windowsserver2008建站
    一、搭建默认网站1、打开服务器管理,选择添加角色。 2、选择服务器角色,勾选web服务器。 3、点击下一步。 4、点击下一步。勾选应用程序开发。点击下一步。 5、......
  • Winsw将jar-bat-nacos-seata-nginx等快捷部署为windows服务
    Winsw将jar-bat-nacos-seata-nginx等快捷部署为windows服务1.软件下载WinSW的github下载地址:https://github.com/winsw/winsw/releases本文以WinSWv2.11.0为例2.注意......
  • 深入浅出学习透析 Nginx 服务器的基本原理和配置指南「运维操作实战篇」
    Nginx前提回顾Nginx是一个高性能的Web和反向代理服务器,它具有有很多非常优越的特性:Web服务器:相比Apache,Nginx使用更少的资源,支持更多的并发连接,体现更高的效率,这点......
  • 深入浅出学习透析 Nginx 服务器的基本原理和配置指南「运维操作实战篇」
    Nginx前提回顾Nginx是一个高性能的Web和反向代理服务器,它具有有很多非常优越的特性:Web服务器:相比Apache,Nginx使用更少的资源,支持更多的并发连接,体现更高的效率......