gcp

package
v0.18.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func HLBImmediateIP

func HLBImmediateIP(proxy int) *headers.RequestInterceptor

HLBImmediateIP extracts client ip from gcp hlb and set to X-Real-Ip

Example

Behind a GCP HTTP(S) Load Balancer the real client IP is the second-to-last entry of X-Forwarded-For (the last is the LB itself). HLBImmediateIP copies that address into X-Real-Ip so downstream middleware can trust it. With no additional proxies in front of the LB, pass proxy = 0.

package main

import (
	"github.com/moonrhythm/parapet"
	"github.com/moonrhythm/parapet/pkg/gcp"
)

func main() {
	s := parapet.NewFrontend()
	s.Use(gcp.HLBImmediateIP(0))
	// s.Use(upstream.SingleHost("10.0.0.1:8080")) — the backend handler.
}
Example (ExtraProxies)

When extra reverse proxies sit between the client and the GCP load balancer, each appends its own hop to X-Forwarded-For. Pass the number of those extra hops as proxy so the correct client address is selected.

package main

import (
	"github.com/moonrhythm/parapet"
	"github.com/moonrhythm/parapet/pkg/gcp"
)

func main() {
	s := parapet.NewFrontend()
	s.Use(gcp.HLBImmediateIP(1)) // one proxy hop ahead of the GCP HLB
}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL