Your current location:Home > Latest news text

星际迷航2

Nginx limit_req 限流:几行配置挡住大部分CC攻击_我的网站

传奇故事

一 |     

     一键部署OpenClaw        服务器CPU莫名飙高,带宽跑满,看日志全是同一个IP一秒打来几十个请求——这不是业务火了,是被CC了。    

Hyrox Photo: VCG
    Hyrox Photo: VCGFrom fewer than 1,700 participants at its first Beijing event to around 12,000 in a recent Shenzhen event, Hyrox is rapidly becoming one of China's newest fitness crazes.
Over the weekend, participants from across China packed the Shenzhen World Exhibition and Convention Center for the German fitness race, according to HYRESULT, a platform that tracks Hyrox race results. The event was one of the Chinese stops of the 2026-27 Hyrox season.
Originating in Hamburg, Germany, in 2017, Hyrox was designed as a fitness competition for gym-goers. It combines eight 1-kilometer runs with eight functional workout stations, including sled pushes, indoor rowing, burpees, farmer's carries and wall balls.
Pronounced "high‑rocks", the brand has never formally disclosed where its name originates. Yet it is widely understood to be a portmanteau blending "hybrid" and "rockstar", a nod to the mix of endurance and raw strength demanded by its race format.
Hyrox has experienced remarkable growth in Europe and the US, with some events attracting over 50,000 athletes and 35,000 spectators. After entering the Chinese market in 2024, the sport has expanded rapidly, with more than 500 affiliated gyms now operating in the Chinese mainland, according to the Xinhua News Agency.
This rapid growth reflects Hyrox's appeal as something more than a workout. By combining standardized physical challenges with competition, measurable results and group training, the sport has turned fitness into a social experience for a growing number of young Chinese professionals.
A fitness enthusiast surnamed Zhang who competed in the Shenzhen race for the first time is one of them.
Before the event, he trained about five times a week, with sessions including sled pushes, indoor rowing and running. He also maintained a daily 5-kilometer running routine.
He entered the "open" category and finished in about 2 hours. For him, however, the result was only part of the experience.
"It is not only about seeing what I have achieved through fitness," he told the Global Times. "Seeing so many disciplined people training and competing together gives you a sense of belonging."
That sense of community is becoming a defining feature of Hyrox in China, where a growing number of young people in major cities are swapping the couch for the gym. 
Guo Xin, a sports commentator in Beijing, told the Global Times, "In the past, many people went to the gym to lift weights or run, but their goals could be relatively vague. Hyrox gives them a clear challenge: finish the race and improve their time."
For people who may find it difficult to make new friends after entering the workforce, training together also offers a natural way to build new social circles.
That structure is particularly appealing to young people who want exercise to be both purposeful and social, Guo said.
Many participants train in groups, sharing workout plans, encouraging one another and meeting outside the gym. 
According to Xinhua, Shanghai-based IT professional Zhang Lin, 27, said she initially signed up simply to join the fun. What kept her returning was her training group, where people from different professions trained together, talked about races and had meals on weekends.
The sport has also found a natural home on Chinese social media.
Training check-ins, race-day crowds, finish-line celebrations and photographs of exhausted competitors are easily turned into shareable content. The popular phrase "pay to suffer" has become something of a rallying cry among Hyrox participants, capturing the willingness of young people to spend money to put themselves through an intense physical challenge.
"The atmosphere of the competition, the ritual of crossing the finish line and hitting the gong, and training check-ins are all easy to share on social media," Guo said. "The process of working hard and then seeing the result is itself very infectious."
For many participants, the appeal is not necessarily about winning.
The global ranking system gives amateur athletes a way to see how their performances compare with others around the world, while still allowing them to focus on personal improvement.
The rapid expansion of Hyrox has also attracted attention from China's sports industry. But Wang Dazhao, a sports commentator, cautioned that even though Hyrox has successfully tapped into young people's demand for fitness and social connection, it is ultimately a commercial sports business.
Its long-term development in China remains to be seen, he said.
There are also safety considerations as the sport attracts newcomers. Although Hyrox promotes itself as a competition "for everybody," the races involve sustained high-intensity exercise and can place considerable demand on the cardiovascular system and muscles.
Pacing is key to competing in Hyrox. For recreational athletes who do not exercise regularly, pushing too hard from the start in pursuit of a fast time can carry significant risks. Elite athletes chasing records also face heightened risks as they push their physical limits.
Guo advised beginners to build a basic fitness foundation before chasing race times, gradually improving their running ability, core strength and lower-body strength.
Participants should also pay attention to warm-ups and recovery, particularly around the knees and lower back, and familiarize themselves with the proper form for exercises such as sled pushes and wall balls.
。扛CC的第一道闸门不在代码里,在Nginx的限流模块里,配置成本几乎为零。    limit_req的原理是漏桶:你设定一个速率,超速的请求直接返回503或延迟排队。先用limit_req_zone定义一个计数区,再在location里挂上limit_req,两步完事。    
# nginx.conf 的 http 块里定义限流区
    # 以客户端IP为key,10MB内存可存约16万个IP状态    # rate=10r/s 表示平均每秒最多放行10个请求    limit_req_zone $binary_remote_addr zone=req_per_ip:10m rate=10r/s;    # server 或 location 块里应用    server {    location / {    limit_req zone=req_per_ip burst=20 nodelay;    proxy_pass http://127.0.0.1:8080;    }    }    burst=20是缓冲队列长度,配合nodelay表示突发20个请求立即处理、不排队,超出就直接拒。想对登录、搜索这类昂贵接口管得更严,单独再定义一个rate=2r/s的zone挂上去就行,互不影响。    
# 对登录接口单独限流:每秒2个,突发5个
limit_req_zone $binary_remote_addr zone=login_limit:10m rate=2r/s;

location /login.php {
limit_req zone=login_limit burst=5 nodelay;
# 被限流的请求返回429而不是默认503
limit_req_status 429;
fastcgi_pass 127.0.0.1:9000;
}
    验证很简单:reload之后用ab压一下,ab -n 200 -c 20 https://你的域名/,看返回里有没有429或503;同时tail -f日志确认正常用户没被误伤。

二 | 限流阈值别拍脑袋定,先统计自己站点的正常峰值,设成峰值的两倍左右再逐步收紧。

三 | 限流是防守,如果卡死自己人就本末倒置了。    数据来源:nginx.org官方文档 ngx_http_limit_req_module 模块说明

        
    

申请创业报道,分享创业好点子。点击此处,共同探讨创业新机遇!。

Current article:http://soi.ruwentaqintiaozhupapaigai.shop/news/20260826_444.html

Published on:15:35:13


Related reading
Copyright © 2020-2099 星际迷航2 All Rights Reserved 星际迷航2 Copyright