Hello,
This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
// Simple HTTP server that responds 200 with a test message including client IP. // // Behavior: // - GET returns HTTP/1.1 200 with a message including the requester IP // - HEAD returns the same headers as GET but no body // - Displays incoming X-* headers when present // - If User-Agent contains "curl" or "wget" (case-insensitive), the server // responds with Content-Type: text/plain; otherwise Content-Type: text/html. // - --pem specifies a PEM bundle file (cert chain + private key). When provided, // the server listens on both HTTP (--port) and HTTPS (--tls-port). // Without --pem the server listens on plain HTTP only. // - --look controls which HTML variant is returned for non-CLI agents: // - basic - plain HTML with no external references // - nice - includes Google Font "Noto Sans" (default) // - bootstrap - Bootstrap 5 layout // - tailwind - Tailwind CSS via @tailwindcss/browser@latest // - The URL query parameter "look" (e.g. /?look=nice) overrides --look for // that request only. Values are case-insensitive and must be basic,nice,bootstrap,tailwind. // // Usage: // // go run ok-server.go # binds 0.0.0.0:8080, nice look // go run ok-server.go --look basic // go run ok-server.go -b 127.0.0.1 -p 8080 --look tailwind // go run ok-server.go --pem /path/to/bundle.pem # HTTP :8080 + HTTPS :8443 // go run ok-server.go --pem /path/to/bundle.pem --tls-port 9443 package main import ( "context" "crypto/tls" "flag" "fmt" "html" "net" "net/http" "os" "os/signal" "sort" "strconv" "strings" "syscall" "time" ) const plainTemplate = "Hello, This is a test HTTP server.\n\nYour request came from {ip}.\n\n{proxy_headers_block}Have a nice day!\n" const htmlBasic = `
This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
` const htmlNice = `This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
Simple status page for firewall/testing
Hello,
This is a test HTTP server.
Your request came from {ip_html}.
{proxy_headers_html}Have a nice day!
%s: %sReverse proxy condition: detected via X-* headers.
" + "X-* headers: