0

I accidently deleted the my configuration file of a Nginx site at /etc/nginx/sites-avialable. /etc/nginx/sites-enabled containts on a symlink to the deleted file. Nevertheless (?) the website is still working. Is there any possiblity to recover the file (since Nginx still uses the config)?

  • Not an answer, did you restart nginx since you removed the /etc/nginx/sites-avialable because I don't believe it will serve the sites that were configured in any files located under site-available if it can't find it. But maybe there's a way look at this serverfault.com/questions/361421/… – sebastienvg Sep 12 '16 at 17:11
  • @sebastienvg Thank you very much! The post you referenced worked perfectly. – Ben L Sep 12 '16 at 20:38
0

Since @Ben L confirmed it's working fine, let's make this the answer.

https://serverfault.com/questions/361421/dump-nginx-config-from-running-process

You need a gdb installed to dump memory regions of running process.

Then run this script after you adjusted the pid#

# Set pid of nginx master process here pid=8192 # generate gdb commands from the process's memory mappings using awk cat /proc/$pid/maps | awk '$6 !~ "^/" {split ($1,addrs,"-"); print "dump memory mem_" addrs[1] " 0x" addrs[1] " 0x" addrs[2] ;}END{print "quit"}' > gdb-commands # use gdb with the -x option to dump these memory regions to mem_* files gdb -p $pid -x gdb-commands # look for some (any) nginx.conf text grep worker_connections mem_* grep server_name mem_*

  • Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change. – DavidPostill Sep 13 '16 at 8:38

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.