使用nginx反向代理后端服务,实现负载均衡
2021/9/27 7:14:23
本文主要是介绍使用nginx反向代理后端服务,实现负载均衡,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
背景:生产环境部署后端服务,没有负载均导致服务压力过大,可以启用nginx进行反向代理。
准备:1)后端服务启动在8081(可以修改)
2)nginx监听8080(可以修改),转发请求到8081(和后端服务端口一致)
nginx配置
user root; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; # server server { listen 8080; server_name gateway; charset utf-8; location / { root html/www; index index.html index.htm; # include /etc/nginx/uwsgi_params; proxy_pass http://xx.xx.xx.xx:8081; # 填写真实地址 } error_page 500 502 503 504 /50x.html; # 日志,需要创建好目录 #access_log /code/datafabric/apigateway/log/gateway.access.log; #error_log /code/datafabric/apigateway/log/gateway.error.log; } }
这篇关于使用nginx反向代理后端服务,实现负载均衡的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-03-29fail2ban nginx
- 2024-03-18install nginx proxy manager
- 2024-01-2444从零开始用Rust编写nginx,命令行参数的设计与解析及说明
- 2024-01-22比Nginx更好用的Gateway!
- 2024-01-17nginx daemon off
- 2023-12-30Nginx Vhost Traffic Status 是什么意思-icode9专业技术文章分享
- 2023-12-26使用nginx搭建creates.io镜像(稀疏索引)
- 2023-11-18centos7编译安装Nginx教程。
- 2023-11-02nginx启动命令和停止命令
- 2023-10-25Centos7系统Nginx负载均衡如何安装和配置?