nginx - Show in php how many 502 errors the server has -


i want show using php how many 502 errors server(nginx) have in last 24 hours. couldn't find simple way thanks!

there no single way this. better solution, proxy server accepting requests local ip address. work (not tested)

the simple solution:

grep '502' access.log | wc -l 

the complex solution:

http {   upstream error_logger {     server 127.0.0.1:80   } } server {   error_page 502 /502.html   location / {    # config here   }   location /502.html {     internal;     proxy_pass http://error_logger/502.php;   } } 

the script (502.php);

  <?php   if($_server['remote_addr'] != '127.0.0.1') die();   // logging here 

Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

how to receive file in java(servlet/jsp) -