Nginx 基础应用实战 03 基于反向代理的负载均衡、https配置

Nginx 基础应用实战 03

反向代理

proxy_pass http://baidu.com;

复制代码
        location /mashibing {
           
	proxy_pass http://mashibing.com/;
        }

基于反向代理的负载均衡

复制代码
  upstream httpd {
    server 192.168.43.152:80;
    server 192.168.43.153:80;
}
weight(权重)

指定轮询几率,weight和访问比率成正比,用于后端服务器性能不均的情况。

复制代码
upstream httpds {
    server 127.0.0.1:8050       weight=10 down;
    server 127.0.0.1:8060       weight=1;
     server 127.0.0.1:8060      weight=1 backup;
}
  • down:表示当前的server暂时不参与负载
  • weight:默认为1.weight越大,负载的权重就越大。
  • backup: 其它所有的非backup机器down或者忙的时候,请求backup机器。

代理服务的安全问题

在公网配置HTTPS

Nginx配置

复制代码
     server {
             listen       443 ssl;
             server_name  aa.abc.com;

             ssl_certificate      /data/cert/server.crt;
             ssl_certificate_key  /data/cert/server.key;

     }

免费签名

https://freessl.cn

阿里云

相关推荐
yashuk21 小时前
Ubuntu 系统下安装 Nginx
数据库·nginx·ubuntu
wydaicls21 小时前
什么时候触发负载均衡(kernel 6.12)
运维·负载均衡
桌面运维家1 天前
Nginx服务器安全:高级访问控制与流量清洗实战
服务器·nginx·安全
yhole1 天前
Nginx解决前端跨域问题
运维·前端·nginx
问道飞鱼1 天前
【服务器知识】nginx安全架构巡检
服务器·nginx·安全架构
斌味代码2 天前
Nginx 配置实战(2026最新版):反向代理+负载均衡+HTTPS+性能优化一网打尽
nginx·https·负载均衡
yj_xqj2 天前
HAproxy负载均衡集群部署
运维·负载均衡
qzhqbb2 天前
Web 服务器(Nginx、Apache)
服务器·前端·nginx
先跑起来再说2 天前
从原理到实践:彻底搞懂Cookie和Session的区别
计算机网络·http·https
ZHENGZJM2 天前
负载均衡式在线评测系统(Load-Balanced Online OJ)技术全景指南
c++·负载均衡·软件工程·idea