NgInx: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(→Tipps) |
(→Tipps) |
||
Zeile 43: | Zeile 43: | ||
= Tipps = | = Tipps = | ||
* Debugging einschalten: | * Debugging einschalten: Reihenfolge ist entscheidend! | ||
** rewrite_log on; | |||
** error_log xxx debug; | |||
** oder error_log xxx notice; | |||
= Logauswertung = | = Logauswertung = |
Version vom 13. August 2019, 17:25 Uhr
Installation
apt-get install php5-cli php5-fpm nginx-full mariadb-server mariadb-client php5-mysql
Konfiguration
server { listen 80; server_name emex; root /home/www/emex; index index.php index.html; location /home/www/emex { try_files $uri $uri/ /index.php?q=$uri&$args; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } }
Neueste Version unter Debian
cat <<EOS >/etc/apt/sources.list.d/nginx.list deb http://ftp.debian.org/debian/ testing main contrib non-free deb-src http://ftp.debian.org/debian/ testing main contrib non-free EOS cat <<EOS >> /etc/apt/preference Package: nginx Pin: release a=testing Pin-Priority: 900 EOS apt-get update # Info ueber verfuegbare Version: apt-cache policy nginx apt-get install nginx-full
Tipps
- Debugging einschalten: Reihenfolge ist entscheidend!
- rewrite_log on;
- error_log xxx debug;
- oder error_log xxx notice;
Logauswertung
#! /bin/bash DATE=$1 if [ -z "$DATE" ] ; then echo "Usage: NgLogTimes <date> <file1> <file2>" echo "Example NgLogTimes 22/Nov/2017 *.gz" else shift while [ -n "$1" ] ; do FN=$1 shift X=$(file $FN | grep "gzip compressed data") if [ -n "$X" ] ; then CMD=zcat else CMD=cat fi #10.10.10.1 - - [27/Nov/2017:06:31:36 +0100] "GET /index.php?option=com_users&view=registration HTTP/1.0" 200 14652 "http://harmonicbrass.de/index.php?option=com_users&view=registration" "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.1144" $CMD $FN | perl -n -e "print \"\$1 Status: \$2\n\" if m!($DATE[0-9:]+).*GET [^\"]+\" ([0-9]+) !;" done fi
Reale IP im Logging hinter Inverse Proxy
Auf dem Server mit inversem Proxy
#### Test, ob in NGINX freigeschaltet: nginx -V 2>&1 | grep --only-matching http_realip_module cat <<'EOS' >/etc/nginx/conf.d/real_ip.conf proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; EOS systemctl nginx reload
Auf dem Server hinter dem Proxy
- in /etc/nginx/nginx.conf
## # Logging Settings ## log_format proxyLog '$remote_addr => $http_x_real_ip - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' '"$http_referer" "$http_user_agent"';