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

推荐订阅源

N
News and Events Feed by Topic
S
SegmentFault 最新的问题
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
Jina AI
Jina AI
H
Help Net Security
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
L
LangChain Blog
Recorded Future
Recorded Future
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
I
InfoQ
GbyAI
GbyAI
B
Blog RSS Feed
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
M
MIT News - Artificial intelligence
爱范儿
爱范儿
V
V2EX
Microsoft Azure Blog
Microsoft Azure Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Y
Y Combinator Blog
B
Blog
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
W
WeLiveSecurity
MongoDB | Blog
MongoDB | Blog
Cloudbric
Cloudbric
N
News and Events Feed by Topic
The Cloudflare Blog
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
有赞技术团队
有赞技术团队
D
DataBreaches.Net
博客园 - 【当耐特】
T
Troy Hunt's Blog
V
Visual Studio Blog
V2EX - 技术
V2EX - 技术
Apple Machine Learning Research
Apple Machine Learning Research
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Google Online Security Blog
Google Online Security Blog
The GitHub Blog
The GitHub Blog

nginx on 打工人日志

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