Skip to content

Phase Flow in Peakhour.IO#

This diagram illustrates the order and flow of phases in Peakhour.IO's request processing pipeline.

graph TD
    A[Incoming Request] --> B[Request Rewrite]
    B --> C[URL Configuration]
    C --> D[Firewall]
    D --> E[Rate Limit Request]
    E --> F[Request Headers]
    F --> G[Load Balance]
    G --> H[Origin Processing]
    H --> I[Response Headers]
    I --> J[Rate Limit Response]
    J --> K[Outgoing Response]

    style A fill:#f9f,stroke:#333,stroke-width:2px
    style K fill:#9ff,stroke:#333,stroke-width:2px
    style H fill:#ff9,stroke:#333,stroke-width:2px

Phase Descriptions#

  1. Request Rewrite: Modifies incoming requests before further processing.
  2. URL Configuration: Updates vconf of matched URL configs based on request headers.
  3. Firewall: Allows, blocks, or challenges requests based on specified conditions.
  4. Rate Limit Request: Applies rate limiting to incoming requests.
  5. Request Headers: Modifies or sets headers in the incoming request.
  6. Load Balance: Distributes incoming requests across multiple servers.
  7. Origin Processing: Handles the request at the origin server.
  8. Response Headers: Modifies or sets headers in the outgoing response.
  9. Rate Limit Response: Applies rate limiting based on the response.

Peakhour-Specific Fields#

Location Field#

The peakhour.server.name field contains the POP server name that handled the request. This field enables origin selection based on region.

Example usage:

peakhour.server.name == "SYD1":

Action:

  lb.origin_pool.set:
    pool: "australia_servers"

Proxy Field#

The peakhour.proxy field detects residential proxies.

Example usage:

peakhour.client.proxy

Action:

  firewall.challenge:
    reason: "Proxy detected"

Firewall Challenge#

The firewall phase includes a challenge action for potentially suspicious requests:

user_agent.bot and not bot.verified:

Action:

  firewall.challenge:
    reason: "Unverified bot"

Dynamic Headers#

Dynamic headers set header values using Wirefilter expressions.

Example:

http.request.headers.set:
  X-User-Location: ${concat(ip.geoip.country, "-", ip.geoip.asnum)}

This sets the X-User-Location header with the country code and AS number of the requesting IP.