In the context of the widespread adoption of generative AI applications, unified AI model gateways built on open-source projects (such as QuantumNous/new-api) have become the core channel for many enterprises and developers to access OpenAI, Claude, Gemini, and DeepSeek. However, as a key node for aggregating and forwarding compute power, NewAPI relay stations, once connected to the public internet, quickly become prime targets for hackers and resource thieves.
SecurityWeek, citing research from Akamai, points out that application-layer (Layer 7) DDoS attacks against applications and APIs have surged by 104% over the past three years, with attackers using automated tools and scripts to frequently overwhelm public API endpoints. For operations teams running NewAPI, they must not only deal with malicious CC traffic but also ensure low-latency streaming responses (SSE) and prevent leakage of the origin server's real IP.
1. Three Major Network and Security Challenges Facing NewAPI Relay Stations
When NewAPI is directly exposed to the public internet without a protective architecture, relay stations typically face the following technical bottlenecks:
- Application-layer (L7) CC attacks and API endpoint abuse: Attackers use distributed HTTP scripts to launch massive concurrent requests against high-consumption endpoints like
/v1/chat/completions, which can easily cause the API gateway's CPU to spike, exhaust database connection pools, or quickly consume all concurrent quotas. - SSE streaming latency and disconnections: Large model text generation relies on Server-Sent Events (SSE) for typewriter-like effects. If standard CDN nodes without optimization are used, their default HTTP response buffering mechanism can cause significant first-packet latency, leading to long freezes or timeouts on the client side.
- Origin server IP exposure leading to bypassed defenses: Once the origin server IP of the relay station is exposed, attackers can directly launch TCP SYN floods or Layer 7 flood attacks against the origin, bypassing the domain-resolved protection layer and directly overwhelming the server.
2. Deploying a "High-Defense CDN + Intelligent WAF" Defense Architecture
The key to solving these problems is to move the protection boundary to the edge nodes. By placing a high-defense CDN with API security protection and network acceleration in front of the NewAPI relay station, you can effectively block the vast majority of malicious traffic.

1. Disable Response Buffering to Ensure Streaming Experience
At the CDN edge nodes and reverse proxy settings, you must enable streaming passthrough for API forwarding routes. By configuring the X-Accel-Buffering: no header and disabling the CDN buffering mechanism for API domains, you ensure that SSE stream responses are delivered to clients in real time, improving first-token response speed.
2. Fine-Grained Rate Limiting and Token Validation
Use edge WAF to identify request characteristics and intercept non-compliant HTTP requests (such as those missing Authorization headers or with malformed JSON payloads) directly at the edge. Additionally, set request frequency thresholds based on IP and token dimensions to smooth out bursty malicious concurrency.
3. Origin Hiding and CN2 Dedicated Line Optimization
Through high-defense CDN nodes, provide Anycast global network access, and use firewalls to restrict the origin server to only accept traffic from trusted IP ranges of CDN edge nodes. Combine this with dedicated lines in China (such as CN2) for origin fetch acceleration to reduce cross-border latency between the relay station and upstream large model APIs.
3. RockCloud Security Solution Integration in NewAPI Scenarios
Addressing the specific needs of NewAPI relay station operators, RockCloud provides supporting protection capabilities based on its mature security and network infrastructure:
- Intelligent WAF and Application-Layer CC Defense: RockCloud's intelligent WAF can identify forged clients and automated bot scripts, intercepting massive malicious requests at the edge in real time to ensure uninterrupted NewAPI operations.
- High-Defense CDN and Anycast Scrubbing: Provides high-capacity DDoS scrubbing capabilities and node protection, effectively blocking large volume flood attacks and hiding the origin server IP.
- CN2 Dedicated Line and Streaming Adaptation: Supports network parameter tuning for API streaming responses, combined with RockCloud's CN2 China dedicated line for origin fetch, reducing cross-border API call latency and providing a smoother AI conversation experience.
4. Practical Checklist for NewAPI Operations Teams
- Enable Edge WAF Basic Rules: Set blocking policies for probing requests without valid API keys.
- Check CDN Cache and Buffering Configuration: Ensure that streaming responses under the
/v1/path have CDN static caching and response buffering disabled. - Configure Origin Security Groups: Only allow protected node IPs to access the origin server's 80/443 ports, eliminating the risk of direct exposure.
- Regularly Audit Logs and Abnormal Calls: Analyze abnormally high API consumption logs and promptly ban risky accounts and access sources.
Comments(0)