randomipv6

package module
v0.0.0-...-544268b Latest Latest
Warning

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

Go to latest
Published: May 25, 2025 License: CC0-1.0 Imports: 6 Imported by: 0

README

caddy-randomipv6

Trying to create an IPv6_Randomizer to hide the users ip at reverse proxies. Made for my mastodon instance, previously using LUA with openresty.

After quite some config attempts, this is how it works in a Caddyfile.

I don't know why, but X-Forwarded-For kept getting overwritten until I did a header_up with ... the X-Forwarded-For Header? Which then used the modules generated random ipv6.

For randomizing within php environment:

domain.tld {
  root /var/www/html/public
  file_server

  randomipv6
  php_fastcgi unix//run/php/php8.4-fpm.sock {
    header_up X-Forwarded-For {header.X-Forwarded-For}
  }
}

For randomizing for a reverse proxy:

domain.tld {
  randomipv6
  reverse_proxy http://127.0.0.1:8080 {
    header_up X-Forwarded-For {header.X-Forwarded-For}
  }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RandomIPv6

type RandomIPv6 struct{}

RandomIPv6 is a Caddy HTTP middleware module that injects a randomized IPv6 address into the X-Real-IP and X-Forwarded-For headers per request.

func (RandomIPv6) CaddyModule

func (RandomIPv6) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (*RandomIPv6) ServeHTTP

func (r *RandomIPv6) ServeHTTP(w http.ResponseWriter, req *http.Request, next caddyhttp.Handler) error

ServeHTTP generates a new random IPv6 address for each request, sets it into the required headers, and then passes control to the next handler.

Jump to

Keyboard shortcuts

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