惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
Security Latest
Security Latest
Simon Willison's Weblog
Simon Willison's Weblog
O
OpenAI News
GbyAI
GbyAI
L
LINUX DO - 最新话题
A
Arctic Wolf
T
Tor Project blog
G
GRAHAM CLULEY
I
InfoQ
博客园_首页
IT之家
IT之家
The Register - Security
The Register - Security
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Proofpoint News Feed
The GitHub Blog
The GitHub Blog
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
K
Kaspersky official blog
博客园 - 三生石上(FineUI控件)
S
SegmentFault 最新的问题
U
Unit 42
PCI Perspectives
PCI Perspectives
量子位
P
Palo Alto Networks Blog
S
Securelist
T
Troy Hunt's Blog
博客园 - 【当耐特】
Recorded Future
Recorded Future
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
S
Security Affairs
Engineering at Meta
Engineering at Meta
T
The Blog of Author Tim Ferriss
博客园 - 聂微东
罗磊的独立博客
N
News and Events Feed by Topic
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
NISL@THU
NISL@THU
C
Cisco Blogs
T
Threatpost
有赞技术团队
有赞技术团队
Forbes - Security
Forbes - Security
Hugging Face - Blog
Hugging Face - Blog
Last Week in AI
Last Week in AI
T
The Exploit Database - CXSecurity.com
Cloudbric
Cloudbric
Cyberwarzone
Cyberwarzone
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security

linux on 打工人日志

使用TLSv1.3 升级nginx和openssl nginx 配置和编译 nginx ssh-key connection exception centos7.9 网络配置 nginx 编译参数详解 nginx 重写规则 rewrite模块 nginx.conf 配置文件详解 nginx 日志格式整理 linux系统开启root权限
nginx 汇总
2021-12-08 · via linux on 打工人日志

本页内容


nginx 汇总

各类 nginx 问题汇总

安装 nginx

1    #centos
2    yum install nginx
3    #ubuntu
4    apt install nginx

http 代理

正向代理

1    server {
2        listen       80;
3        server_name  www.nbtyfood.com;
4
5        location / {
6            proxy_pass http://127.0.0.1:8080;
7        }
8    }

反向代理

负载均衡

 1    upstream mysvr {
 2    server 192.168.10.121:3333;
 3    server 192.168.10.122:3333;
 4    }
 5    server {
 6        ....
 7        location  ~*^.+$ {
 8            proxy_pass  http://mysvr;  #请求转向mysvr 定义的服务器列表
 9        }
10    }
  1. 热备
    如果你有 2 台服务器,当一台服务器发生事故时,才启用第二台服务器给提供服务。服务器处理请求的顺序:AAAAAA 突然 A 挂啦,BBBBBBBBBBBBBB…..
1    upstream mysvr {
2    server 127.0.0.1:7878;
3    server 192.168.10.121:3333 backup;  #热备
4    }
  1. 轮询
    nginx 默认就是轮询其权重都默认为 1,服务器处理请求的顺序:ABABABABAB….
1    upstream mysvr {
2    server 127.0.0.1:7878;
3    server 192.168.10.121:3333;
4    }
  1. 加权轮询
    跟据配置的权重的大小而分发给不同服务器不同数量的请求。如果不设置,则默认为 1。下面服务器的请求顺序为:ABBABBABBABBABB….
1    upstream mysvr {
2    server 127.0.0.1:7878 weight=1;w
3    server 192.168.10.121:3333 weight=2;
4    }
  1. ip_hash nginx 会让相同的客户端 ip 请求相同的服务器。
1    upstream mysvr {
2    server 127.0.0.1:7878;
3    server 192.168.10.121:3333;
4    ip_hash;
5    }

web 缓存

1    location /images/ {
2    proxy_cache my_cache;
3    proxy_ignore_headers Cache-Control;
4    proxy_cache_valid any 30m;
5    # ...
6}

重定向

1    rewrite ^/(.*) http://www.nbtyfood.com/$1 permanent;