0

I have an nginx reverse-proxy on a ubuntu server in AWS. How can I see when it's configurations were reloaded, either via CLI or otherwise, and when it was restarted altogether?

If it doesn't record these events on its own, how can I log them indirectly through a script of some kind?

4
  • Is your nginx server running as a systemd service?
    – Uberhumus
    Nov 20 at 14:52
  • If your nginx has a lua module enabled then you could use init_by_lua_block to write to log file on config reload/restart.
    – Alexey Ten
    Nov 20 at 15:57
  • @Uberhumus yes it is
    – simboyd
    Nov 20 at 16:35
  • @AlexeyTen ok I will research this approach further
    – simboyd
    Nov 20 at 16:35

1 Answer 1

0

With some auditd rules

-a always,exit -F path=/usr/sbin/nginx -k nginx_exec
-a always,exit -F arch=b64 -S kill -F a0=1 -F a1=9 -k nginx_restart
-a always,exit -F arch=b64 -S kill -F a0=1 -F a1=1 -k nginx_reload

You can then check with

ausearch -k nginx_exec
ausearch -k nginx_restart
ausearch -k nginx_reload

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .