Hello,
This is a test HTTP server.
Your request came from {ip}.
{proxy_headers_html}Have a nice day!
#!/usr/bin/env node /** * 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. * - --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 * - 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. */ import http from "node:http"; import { URL } from "node:url"; const VALID_LOOKS = new Set(["basic", "nice", "bootstrap"]); const PLAIN_TEMPLATE = "Hello, This is a test HTTP server.\n\n" + "Your request came from {ip}.\n\n" + "{proxy_headers_block}" + "Have a nice day!\n"; const HTML_BASIC = `
This is a test HTTP server.
Your request came from {ip}.
{proxy_headers_html}Have a nice day!
`; const HTML_NICE = `This is a test HTTP server.
Your request came from {ip}.
{proxy_headers_html}Have a nice day!
This is a test HTTP server.
Your request came from {ip}.
{proxy_headers_html}Have a nice day!
${escapeHtml(name)}: ${escapeHtml(value)}Reverse proxy condition: detected via X-* headers.
" + `X-* headers: