# format like 'main' excluding user agent log_format mtt '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer"'; access_log off; upstream fpm { server php-fpm:9000; } server { listen 80; server_name localhost; root /var/www/html; # same as php-fpm access_log /var/log/nginx/access.log mtt; index index.php index.html; autoindex off; location = /phpinfo { include fastcgi_params; fastcgi_param SCRIPT_FILENAME /var/www/phpinfo/phpinfo.php; fastcgi_pass fpm; } location /api/ { rewrite ^/api/(.*) /api.php/$1 last; } location / { try_files $uri $uri/ =404; } location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_index index.php; fastcgi_pass fpm; } location /db/ { return 404; #deny all } location /includes/ { return 404; #deny all } location ~ /\.ht { return 404; #deny all } }