vue 用Nginx实现负载均衡

Nginx负载均衡的作用(相当于客户端的请求是发到Nginx上的,然后由Nginx决定到底调用哪台服务器):

在 .net core 中的具体实现步骤

1.在nginx官网上下载安装包,推荐稳定版; 建议1.18版本

2.下载完成后,到所在目录执行 nginx绿色图表 运行nginx(建议使用管理员模式运行),在任务管理器观察是否已经运行

或者在cmd到该目录执行nginx命令,如果需要停止nginx -s stop

找到 conf 下面的 nginx 配置如下即可

upstream local-cjstore{

server 127.0.0.1:83 weight=1;

server 127.0.0.1:84 weight=1;

server 127.0.0.1:85 weight=1;

}

server {

listen 9090;

server_name 127.0.0.1;

#charset koi8-r;

#access_log logs/host.access.log main;

location / {

proxy_pass http://local-cjstore;

proxy_set_header Host $http_host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

proxy_set_header X-NginX-Proxy true;

}

#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 html;

}

}

vue 前端的配置就已完成运行nginx即可

相关推荐
Ai拆代码的曹操5 小时前
Nginx upstream keepalive 连接池中毒排查实录
chrome·nginx·php
滴滴答答哒6 小时前
VUE3+element-plus MultiSelect 多选下拉组件
前端·javascript·vue.js
其美杰布-富贵-李6 小时前
04 watch 与 Vue 响应式数据流
前端·javascript·vue.js
其美杰布-富贵-李9 小时前
03 ref、reactive 与 computed 响应式数据
前端·javascript·vue.js
嘟嘟071710 小时前
useRef + Web Worker:React 中的耗时计算不卡页面
javascript·vue.js
万敏10 小时前
Vue3 全栈实战第五周:Vitest 单元测试从零搭建实战记录
vue.js·node.js·全栈
sugar__salt12 小时前
跟着 Demo 学 Pinia:两种仓库写法 + 完整 TodoList 复现
前端·javascript·vue.js·前端框架·vue
空谷有来人14 小时前
Ubuntu22.04上安装配置站点
nginx
PC2005-cloud15 小时前
KubeSphere学习笔记:部署nginx
笔记·学习·nginx
后除16 小时前
Debian 安装与使用 Certbot
后端·nginx·https