Troubleshoot clients with netcat

netcat can be used as a server daemon to troubleshoot clients.

Web server

netcat(1) can be used to mimic a web server by running the following command:

  1. nc -c -C /etc/ssl/example.com.crt -K /etc/ssl/private/example.com.key -l 443

The public and private keys example.com.{crt,key} should be first requested using acme-client.

Then, use your web browser to visit the webpage https://example.com to see the client's request:

GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0 (X11; rv:128.0) Gecko/20100101 Firefox/128.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/png,image/svg+xml,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br, zstd
DNT: 1
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
If-Modified-Since: Tue, 12 Nov 2024 06:15:19 GMT
Priority: u=0, i