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

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

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;