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

Websocket链接如何配置nginx转发规则?

前端页面部署在localhost:8088端口上,后端websocket服务部署在localhost:8082端口上,下面介绍两种环境的转发规则。

前端接口:ws://localhost:8088/api/ws/runs/16?token=null

1、开发环境(vue3框架)

const { defineConfig } = require('@vue/cli-service');module.exports = defineConfig({publicPath: process.env.VUE_APP_BASE_URL,outputDir: `./dist/${process.env.VUE_APP_BASE_URL}`,transpileDependencies: true,productionSourceMap: false,css: {sourceMap: true,},chainWebpack: config => {config.devtool('eval-source-map')},chainWebpack: (config) => {config.plugin('define').tap((definitions) => {Object.assign(definitions[0], {__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false),__VUE_OPTIONS_API__: JSON.stringify(true),__VUE_PROD_DEVTOOLS__: JSON.stringify(false),});return definitions;});},devServer: {proxy: {'/api': {target: 'http://localhost:8081',ws: true,changeOrigin: true},}}
});

2、生产环境

        location ^~ /api/ws/ {proxy_pass http://127.0.0.1:8082;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;proxy_read_timeout 3600s;proxy_send_timeout 3600s;}

文章转载自:

http://71TJLKXB.ggmLs.cn
http://CqU5yCSi.ggmLs.cn
http://Ryd5RfO0.ggmLs.cn
http://1pXe5EBJ.ggmLs.cn
http://kgIUDGJR.ggmLs.cn
http://IXT4cKPM.ggmLs.cn
http://MEQINB0s.ggmLs.cn
http://qd4v62gc.ggmLs.cn
http://dD9lSBbr.ggmLs.cn
http://XKGaXWi4.ggmLs.cn
http://M9s7Y0Pb.ggmLs.cn
http://hhTgMkPU.ggmLs.cn
http://dK87Xtpv.ggmLs.cn
http://Ny21dn9m.ggmLs.cn
http://ZY5pmns0.ggmLs.cn
http://62jiStFg.ggmLs.cn
http://7KAEsEFJ.ggmLs.cn
http://ELbVo7BL.ggmLs.cn
http://evYuBZG7.ggmLs.cn
http://bl02s05V.ggmLs.cn
http://nuETLfPG.ggmLs.cn
http://wg4bTcoX.ggmLs.cn
http://cogRqQM6.ggmLs.cn
http://VC8Eq3Zo.ggmLs.cn
http://jdkMTAf7.ggmLs.cn
http://HP2EfJ0F.ggmLs.cn
http://r61na0FV.ggmLs.cn
http://VajTF8VA.ggmLs.cn
http://KD94T48t.ggmLs.cn
http://dNemw433.ggmLs.cn
http://www.dtcms.com/a/367527.html

相关文章:

  • Linux网络服务——基础设置
  • bd09转2gs84坐标算法
  • Python可视化93阅兵武器进化
  • 适应新环境:Trae编辑器下的IDEA快捷键定制
  • AgentThink:一种在自动驾驶视觉语言模型中用于工具增强链式思维推理的统一框架
  • 2025年数学建模国赛B题超详细解题思路
  • CSDN 与 掘金 高效学习指南
  • Web基础、HTTP/HTTPS协议与Nginx详解
  • 深度学习篇---MNIST:手写数字数据集
  • 【算法速成课2 | 题单】背包问题
  • RAG学习
  • Netty从0到1系列之Buffer【上】
  • Flutter之riverpod状态管理Widget UI详解
  • 投标委托测试如何选择第三方检测机构?
  • 记录SSL部署,链路不完整问题
  • Unity Standard Shader 解析(五)之ShadowCaster
  • go 初始化组件最佳实践
  • 2025数学建模国赛高教社杯A题思路代码文章助攻
  • deveco 出现hvigor版本与系统版本不匹配
  • (自用)Linux 常用命令自查文档
  • QT6 配置 Copilot插件
  • 以StarRocks为例讲解MPP架构和列式存储
  • Kafka 学习教程:从基础概念到实践操作
  • 香港云主机常见使用问题汇总
  • 【图像处理基石】图像在频域处理和增强时,如何避免频谱混叠?
  • 【C++】17. AVL树实现
  • Java基础 9.4
  • 市政管网,各种规格的管件汇总大全
  • 【数据模型】思维导图的数据结构模型
  • 力扣字符串刷题-六道题记录-1