Pour parser les acces Log Nginx il est préférable de modifier le fichier /etc/nginx/nginx.conf :
on modifie le format des logs, ainsi que la destination des fichiers:
## # Logging Settings ## log_format perso '$time_local | ' '$status | ' '$http_x_forwarded_for | ' '$remote_addr | ' '$remote_user | ' '$body_bytes_sent | ' '$http_referer | ' '$request | ' '$http_user_agent'; access_log /home/pi/logs/nginx/access.log perso; error_log /home/pi/logs/nginx/error.log;
et voici le résultat:
05/Mar/2022:10:57:30 +0100 | 200 | - | 192.168.1.79 | - | 5 | - | GET /meteo/php/logs.php?Host=ESP-16&Vent=2.51&Rafale=3.23&Compas=279 HTTP/1.1 | ESP8266HTTPClient 05/Mar/2022:10:57:40 +0100 | 200 | - | 192.168.6.111 | - | 5 | - | GET /meteo/php/logs.php?Host=ESP-15&PluRel=0.00&PluInt=0.00 HTTP/1.1 | ESP8266HTTPClient 05/Mar/2022:10:58:00 +0100 | 200 | - | 192.168.1.79 | - | 5 | - | GET /meteo/php/logs.php?Host=ESP-16&&Vent=0.89&Rafale=2.42&Compas=166 HTTP/1.1 | ESP8266HTTPClient 05/Mar/2022:10:58:11 +0100 | 200 | - | 192.168.6.89 | - | 5 | - | GET /meteo/php/logs.php?Host=ESP-04&Tmp=9.72&Hum=69.01&TBME=11.44&HBME=67.75&PR=1021.21&PA=1012.88 HTTP/1.1 | ESP8266HTTPClientESP8266HTTPClient
ensuite on configure les virtualhost en modifiant le fichier /etc/nginx/sites-available/monsite :
server { listen 80; listen [::]:80; server_name monsite.net; root /var/www/monsite; index index.php index.html index.htm index.nginx-debian.html; access_log /home/pi/logs/monsite_access.log perso; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/run/php/php7.4-fpm.sock; } }
ensuite il faut verifier si la nouvelle configuration est correcte et la recharger.
286