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;
        }
    }
}
相关推荐
weipt34 分钟前
利用wsl给windows电脑上安装一个ubuntu
linux·运维·ubuntu
jarreyer42 分钟前
【软件操作】加快资源管理器打开速度
运维
万敏42 分钟前
Vue3 全栈实战:第一阶段复盘(第1-8周)
vue.js·node.js·全栈
梨想橙汁43 分钟前
Vue3 组合式 API 深度解析:ref/reactive 响应式,计算属性与侦听器
前端·vue.js
楚疏笃1 小时前
linux下给OpenCloudOS根目录扩容
linux·运维·服务器
dog2501 小时前
网络的时延抖动
linux·运维·网络
web打印社区1 小时前
浏览器静默打印?先别装第三个库了
前端·vue.js·chrome·electron·pdf
程序员-Benothing1 小时前
Linux 软件包管理:yum / apt / dnf 命令使用全解析
linux·运维·服务器
DevangLic2 小时前
opencode go要完蛋了吗
运维·学习