From 1a941c14c68e6ad4741ece694cdd2f7bec353420 Mon Sep 17 00:00:00 2001 From: alexweissman Date: Wed, 9 Aug 2017 00:37:01 -0400 Subject: [PATCH] Add Pagespeed block (commented out) to nginx config file --- CHANGELOG.md | 2 ++ webserver-configs/nginx.conf | 39 +++++++++++++++++++++++++++--------- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 287f65030..0588582e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ - Reimplement `Builder::exclude` to maintain a list of excluded columns, and then automatically update list of columns to fetch in `get()` - Deprecate `Model::queryBuilder` and `Model::export` - Update nginx config file from spdy to http2 +- Add Pagespeed block (commented out) to nginx config file +- Make fpm-php7.0 the default CGI nginx config file ## v4.1.7-alpha - Add the `withTernary` method to the `Unique` trait to allow loading nested child models on ternary relationships. diff --git a/webserver-configs/nginx.conf b/webserver-configs/nginx.conf index 69110e1b6..354c683e1 100644 --- a/webserver-configs/nginx.conf +++ b/webserver-configs/nginx.conf @@ -1,5 +1,5 @@ -## This is just a starting point for configuring your application. It is not guaranteed to work out of the box. -## See https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/ +## UserFrosting sample nginx configuration file. +## See https://learn.userfrosting.com/going-live/vps-production-environment/application-setup#configure-the-webserver-nginx- ## Redirect HTTP to HTTPS ## Enable this block once you've set up SSL. This will redirect all HTTP requests to HTTPS. @@ -9,8 +9,7 @@ # return 301 https://$host$request_uri; #} -# Default server configuration -# +## Main server configuration server { ## Non-SSL configuration. Not recommended for production! listen 80; @@ -50,6 +49,7 @@ server { #ssl_trusted_certificate /etc/letsencrypt/live//fullchain.pem; # same as your ssl_certificate path ## Config to enable HSTS(HTTP Strict Transport Security) https://developer.mozilla.org/en-US/docs/Security/HTTP_Strict_Transport_Security #add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; + ## End - SSL configuration access_log /var/log/nginx/access.log; @@ -58,12 +58,29 @@ server { ## This header enables the Cross-site scripting (XSS) filter built into most recent web browsers. add_header X-XSS-Protection "1; mode=block"; #optional - # Allow URLs for certbot acme challenge (Let's Encrypt) + ## Begin - Pagespeed + ## See https://learn.userfrosting.com/going-live/vps-production-environment/additional-recommendations + ## for information on compiling nginx with the Pagespeed module. + #pagespeed on; + #pagespeed FileCachePath /var/ngx_pagespeed_cache; + #pagespeed Disallow "*.svg*"; + ## Add additional filters here + #pagespeed EnableFilters prioritize_critical_css; + ## Ensure requests for pagespeed optimized resources go to the pagespeed + ## handler and no extraneous headers get set. + #location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" { add_header "" ""; } + #location ~ "^/ngx_pagespeed_static/" { } + #location ~ "^/ngx_pagespeed_beacon" { } + ## End - Pagespeed + + ## Begin - Let's Encrypt + ## Allow URLs for certbot acme challenge location ~ /.well-known { allow all; } + ## End - Let's Encrypt - ## handle php requests. + ## Begin - Handle PHP requests location ~ \.(php)$ { # Throw away any requests to execute PHP scripts in other directories # See http://cnedelcu.blogspot.com/2010/05/nginx-php-via-fastcgi-important.html for why this is needed @@ -73,10 +90,10 @@ server { # regex to split $uri to $fastcgi_script_name and $fastcgi_path fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_keep_conn on; - # For FPM (PHP 5.x) - fastcgi_pass unix:/var/run/php5-fpm.sock; # For FPM (PHP 7) - #fastcgi_pass unix:/run/php/php7.0-fpm.sock; + fastcgi_pass unix:/run/php/php7.0-fpm.sock; + # For FPM (PHP 5.x) + #fastcgi_pass unix:/var/run/php5-fpm.sock; # For traditional PHP FastCGI (php5-cgi or php7.0-cgi) #fastcgi_pass 127.0.0.1:9000; # For HHVM @@ -85,8 +102,9 @@ server { fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } + ## End - Handle PHP requests - ## we can cache some static files + ## Begin - Caching static files location ~* \.(png|gif|jpg|jpeg|svg|ico|css|js|woff|ttf|otf|woff2|eot)$ { include /etc/nginx/mime.types; expires max; @@ -94,6 +112,7 @@ server { index index.php; try_files $uri $uri/ /index.php?$query_string; } + ## End - Caching static files ## Begin - Index ## for subfolders, simply adjust: