Nginx常用配置
2021-01-29 本文已影响0人
Fuuqiu
处理流量突刺(Bursts)
location /login/ {
#同时到达数超过指定 多出的20个流量会等待 多余的直接返回503
limit_req zone=mylimit burst=20 nodelay;
proxy_pass http://my_upstream
}
拒绝所有请求
location /foo.php {
deny all;
}
Nginx Time:
标识 | 英文 | 中文 |
---|---|---|
ms | milliseconds | 毫秒 |
s | seconds | 秒 |
m | minutes | 分 |
h | hours | 小时 |
d | days | 天 |
w | weeks | 周 |
M | months, 30 days | 月 |
y | years, 365 days | 年 |
压测脚本[多线程]
$ ab -n 100000 -c 40 -p parameter.txt -T application/x-www-form-urlencoded http://tools.com/api/v1/number
监听多个域名
- 一个server多个servername
server {
#监听端口
listen 80;
#请求域名,空格多域名
server_name admin.xx.cn admin.cc.com;
#日志记录
access_log /var/log/nginx/admin.access.log;
return 301 https://$host$request_uri; #重定向https请求
}
- nginx 一个站点支持多端口配置
server {
#监听端口
listen 80;
listen 81;
#请求域名
server_name admin.xx.cn admin.cc.cn;
#日志记录
access_log /var/log/nginx/admin.access.log;
return 301 https://$host$request_uri; #重定向https请求
}