Skip to content

Instantly share code, notes, and snippets.

@pr0way
Created May 14, 2019 14:51
Show Gist options
  • Save pr0way/ce6f0206907b894ae3c5526e79ead4f5 to your computer and use it in GitHub Desktop.
Save pr0way/ce6f0206907b894ae3c5526e79ead4f5 to your computer and use it in GitHub Desktop.
Pagekit config file for nginx servers (working ~ PHP 7.2-FPM)
server {
# Server name
server_name pagekit.local www.pagekit.local;
error_log /var/log/nginx/pagekit.local.error error;
access_log /var/log/nginx/pagekit.local.access;
# Server Port
listen 80;
listen [::]:80;
# Webroot
root /var/www/html/pagekit.local;
# Index file
index index.php;
# PHP setup with query string support
location / {
try_files $uri $uri/ /index.php?$args;
}
# Deny access to sensitive folders
location ~* /tmp/.*$ {
deny all;
}
# Deny access to files with the following extensions
location ~* \.(db|json|lock|dist|md)$ {
return 403;
}
# Deny access to following files
location ~ /(config.php|composer.lock|composer.json|LICENSE|\.htaccess) {
return 403;
}
# Leverage browser caching of media files for 30 days
location ~* \.(?:ico|css|js|gif|jpe?g|png|ttf|woff)$ {
access_log off;
expires 30d;
add_header Pragma public;
add_header Cache-Control "public, mustrevalidate, proxy-revalidate";
}
# PHP 7.2-FPM
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_param HTTP_MOD_REWRITE On;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment