Nginx常用配置

作者: Fuuqiu | 来源:发表于2021-01-29 16:07 被阅读0次

处理流量突刺(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请求
}

相关文章

网友评论

    本文标题:Nginx常用配置

    本文链接:https://www.haomeiwen.com/subject/syfpbktx.html