Skip to navigationSkip to main contentSkip to footerScaleway Docs HomepageAsk our AI
Ask our AI

Serverless Functions HTTP headers reference

Scaleway Serverless Functions automatically inject several HTTP headers into every incoming request. These headers provide metadata about the request, the client, and the routing path through the Scaleway infrastructure.

You can use these headers within your function logic for logging, security, and request tracing.

Injected headers reference

The following headers are available in the request object of your function.

HeaderDescription
X-Forwarded-ForA standard header used to identify the originating IP address of a client connecting through an HTTP proxy or load balancer.
X-Forwarded-ProtoA header indicating the protocol (HTTP or HTTPS) used by the client to connect to the container.
X-Request-IDA unique string assigned to each incoming request to facilitate tracing and debugging.

Alongside these headers, the following headers are set for internal purposes. Users should be careful when using them, as their presence/contents is not guaranteed:

HeaderDescription
K-Proxy-RequestInternal. Used by the underlying architecture.
X-Envoy-External-AddressDeprecated. Prefer using X-Real-IP.

Detailed use cases

Request tracing and debugging

The X-Request-ID header is essential for distributed tracing. Each request receives a unique identifier that persists throughout the lifecycle of the request within the Scaleway ecosystem.

  • Log correlation: Log the X-Request-ID at the start of your function. If a request fails, you can use this ID to search your Serverless Functions logs for entries related to that specific execution. The request ID does not appear in user logs by default. To include it, propagate the header value yourself.
  • Cross-service tracking: If your function calls another service, pass the X-Request-ID along to maintain a consistent trace across your architecture.

Client IP identification

Use the X-Real-IP header to identify the IP address of the client. It contains the list of IP addresses the request has passed through, with the original client IP as the first entry. You can use X-Forwarded-For if the connection has proxies, but note that it can be tampered by the client.

  • Security and filtering: Use X-Real-IP to implement IP-based rate limiting or to allow/deny requests from specific geographic regions within your application logic.
  • Analytics: Use X-Real-IP to determine the general location of your users without relying on internal routing IPs.

Protocol enforcement

The X-Forwarded-Proto header allows your function to determine if the user is connecting over a secure connection.

  • HTTPS redirection: If your function logic requires a secure connection, you can check if X-Forwarded-Proto is http and respond with a redirect to the HTTPS version of your endpoint.
Note

Because Scaleway Serverless Functions are served via HTTPS by default, this header usually reflects https for external requests.

Still need help?

Create a support ticket
No Results