当前位置: 首页 > news >正文

nginx-docker 搭建websocket反向代理

下载镜像

docker pull nginx

复制出配置文件

将/etc/nginx/nginx.conf和/etc/nginx/conf.d/default.conf复制到本机

nginx.conf文件内容

user  nginx;
worker_processes  auto;error_log  /var/log/nginx/error.log notice;
pid        /var/run/nginx.pid;events {worker_connections  1024;
}http {include       /etc/nginx/mime.types;default_type  application/octet-stream;log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';access_log  off;#access_log  /var/log/nginx/access.log  main;sendfile        on;#tcp_nopush     on;keepalive_timeout  65;gzip  on;include /etc/nginx/conf.d/*.conf;
}

default.conf文件内容

server {listen       20000;server_name  localhost;#access_log  /var/log/nginx/host.access.log  main;location /20001/ {proxy_pass http://192.168.2.5:20001/;proxy_http_version 1.1;proxy_set_header Host $http_host;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;proxy_set_header Accept-Encoding gzip;}location /20002/ {proxy_pass http://192.168.2.5:20002/;proxy_http_version 1.1;proxy_set_header Host $http_host;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;proxy_set_header Accept-Encoding gzip;}location /20003/ {proxy_pass http://192.168.2.5:20003/;proxy_http_version 1.1;proxy_set_header Host $http_host;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;proxy_set_header Accept-Encoding gzip;}location /20005/ {proxy_pass http://192.168.2.5:20005/;proxy_http_version 1.1;proxy_set_header Host $http_host;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection upgrade;proxy_set_header Accept-Encoding gzip;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}}

运行

run  --rm  -it  -p 20000:20000 -v /root/app/tmp/nginx.conf:/etc/nginx/nginx.conf -v /root/app/tmp/default.conf:/etc/nginx/conf.d/default.conf  nginx
http://www.lryc.cn/news/271655.html

相关文章:

  • blender插件开发
  • 【数据结构】二叉搜索(查找/排序)树
  • Vue:Vue与VueComponent的关系图
  • Elasticsearch8集群部署
  • 【小白专用】c# 如何获取项目的根目录
  • 【PXIE301-208】基于PXIE总线架构的Serial RapidIO总线通讯协议仿真卡
  • 软件测试/测试开发丨Windows系统chromedriver安装与环境变量配置
  • 【vim 学习系列文章 3.1 -- vim 删除 ^M】
  • 深入理解 C# 中的字符串比较:String.CompareTo vs String.Equals
  • DevOps持续交付之容器化CICD流水线
  • Linux/Unix/国产化操作系统常用命令(二)
  • 基于SpringBoot的智慧生活商城系统
  • Vue框架引入Axios
  • EasyExcel 通过模板 导入、导出、下载模板
  • SAP ABAP通过代码解锁SM12中被锁定目标<转载>(RFC: ENQUEUE_READ和 ENQUE_DELETE)
  • 跳跃表原理及实现
  • 详解Vue3中的鼠标事件mousemove、mouseover和mouseout
  • Java:socket编程
  • 哨兵1号回波数据(L0级)FDBAQ压缩算法详解
  • 盾构机数据可视化监控平台 | 图扑数字孪生
  • 计算机网络课程设计-企业网三层架构
  • Docker上传镜像到Harbor
  • mfc100u.dll文件丢失了要怎么解决?修复mfc100u.dll详细指南
  • 【ArcGIS微课1000例】0084:甘肃积石山地震震中100km范围内历史灾害点分布图(2005-2020)
  • java SSM拖拉机售后管理系统myeclipse开发mysql数据库springMVC模式java编程计算机网页设计
  • 侯捷C++ 2.0 新特性
  • 计算机网络——基础知识汇总(八)
  • DIA数皆智能客户体验管理CEM获伊利“健康+AI”生态创新大奖
  • linux 休眠唤醒中设备、总线、用户进程、内核线程调试分析流程
  • k8s陈述式资源管理(命令行)