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

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

web 服务器 on 打工人日志

使用TLSv1.3 升级nginx和openssl nginx 配置和编译 nginx ssh-key connection exception nginx 编译参数详解 nginx 重写规则 rewrite模块 nginx.conf 配置文件详解 nginx 日志格式整理
nginx 汇总
2021-12-08 · via web 服务器 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;