nginx实现vue和后端的双机负载

nginx配置文件,项目是前后端分离的,前端vue,后端springboot

前端使用nginx实现双机负载,前端的访问端口是95280,后端2个服务实例的端口分部为9098,9099

nginx.conf的配置文件

复制代码
#user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
 
    keepalive_timeout  65;
         
    #这里是配置负载均衡
    upstream xx_front {
        server 127.0.0.1:9098;
		server 127.0.0.1:9099;
    }              
    server {
        listen       9528;
        server_name  xx.xx.xx.xx;
 
        location / {
            root   xx/dist;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }
       #配置由前端路由到后端
        location /data-management/ {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header REMOTE-HOST $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://xx_front;
        }
    }
}
相关推荐
SL-staff1 小时前
AB测试数据失真根因与变量热替换实战:JVS-Rules函数计算器架构解析
java·运维·微服务·函数式编程·规则引擎·变量管理·营销技术
飞飞传输1 小时前
机器人行业数据流转深度研究:内外网数据摆渡平台应用现状与趋势
大数据·运维·安全
皮皮虾❀1 小时前
广州云服务器价格:阿里云代理商折扣报价单指南
运维·服务器·阿里云
xiebingsuccess1 小时前
Ubuntu 22.04 在 VMware 上的安装与远程桌面配置 — 任务报告
linux·运维·ubuntu·ai+嵌入式开发
一颗烂土豆1 小时前
ECharts 太平面?试试这款 Vue 3D 图表库
前端·vue.js·echarts
想要成为老金高手1 小时前
Nginx、PHP、Memcache、Tomcat 与 OpenResty 实验汇总
nginx·php·memcached
郝亚军2 小时前
asqlite-autoconf-3310100 的ubuntu 22.04 aarch64交叉编译
linux·运维·ubuntu
笑锝没心没肺2 小时前
Linux安装docker及运行容器测试
linux·运维·docker
时空无限2 小时前
ubuntu apt 查看软件之间的依赖
linux·运维·ubuntu
Escalating_xu2 小时前
【Linux】进程信号:从产生、阻塞与递达到 sigaction、可重入与内核返回路径
linux·运维·面试·职场和发展