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;
        }
    }
}
相关推荐
Web项目开发13 小时前
Dockerfile创建Almalinux9镜像
linux·运维·服务器
jiayong2319 小时前
DevOps体系详解01-核心概念与价值
运维·devops
a11177620 小时前
医院挂号预约系统(开源 Fastapi+vue2)
前端·vue.js·python·html5·fastapi
jiayong2320 小时前
DevOps体系详解02-技术架构与工具链
运维·架构·devops
pride.li20 小时前
开发板和Linux--nfs服务挂载
linux·运维·服务器
计算机毕设VX:Fegn089520 小时前
计算机毕业设计|基于springboot + vue蛋糕店管理系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
云泽8081 天前
不止是命令:Linux 高频指令实战 + 芯片架构底层逻辑
linux·运维·服务器
j_xxx404_1 天前
Linux:基础IO
linux·运维·服务器
行走的陀螺仪1 天前
uni-app + Vue3编辑页/新增页面给列表页传参
前端·vue.js·uni-app
angushine1 天前
银河麒麟V10创建用户
运维