0

I have a daemon, call it whatverd, running on TCP port 11111. It is basically an http server, but it does not do any kind of logging or debugging. It only returns query results via JSON in the http(s) response, like a normal web server. How can I capture and write http(s) requests and responses to a local file? My options seem to be:

  1. Modify the source code, in a language I don't know at all.
  2. Run an http proxy of some sort.
  3. Run tcpdump and redirect the output to a file.

Is there an obvious 'right' way to do this? Thanks.

PS: It's running on Debian Jessie (8), I do have root, and I can modify the TCP port number that whateverd listens on.

  • What I'm leaning toward is to run a separate http server or proxy on the same system, to listen on port 80, and forward the http requests to whateverd on TCP 111111. The return path would also have to go through the proxy. I just can't tell if this is a job for apache, squid, or something like tinyproxy. – Luke Sheppard Jul 7 '18 at 5:49
  • I think this is the right approach---you probably want what's called a "reverse proxy" sitting in front of your whateverd here. Apache, Nginx, tinyproxy, and maybe squid should all be able to do this, although I think that tinyproxy and squid are slightly more designed to be forward proxies. – Peter Amidon Jul 7 '18 at 18:59
0

I'd just utilize systemd for this, and make a unit-file for your daemon service, whatverd.

$ cat /etc/systemd/system/whatverd.service
[Unit]
Description=whatverd

[Service]
ExecStart=/bin/bash -c "<cmd to run whatverd>"

[Install]
WantedBy=multi-user.target

Then to enable/start it:

$ sudo systemctl daemon-reload
$ sudo systemctl enable whatverd
$ sudo systemctl start whatverd
$ sudo systemctl status whatverd

Now with this setup you can utilize journald via the command journalctl.

References

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.