Skip to content

Instantly share code, notes, and snippets.

@ag7-alexis
Created May 27, 2022 08:27
Show Gist options
  • Save ag7-alexis/1aeedee4031c9bb6c39e728caf8b9028 to your computer and use it in GitHub Desktop.
Save ag7-alexis/1aeedee4031c9bb6c39e728caf8b9028 to your computer and use it in GitHub Desktop.
Nginx server config
map $sent_http_content_type $expires {
default off;
text/html epoch;
text/css max;
application/javascript max;
~image/ max;
}
server {
expires $expires;
root /var/www/html/alexis-blog;
index index.php index.html index.htm;
server_name alexis-guay.fr www.alexis-guay.fr;
error_log /var/log/nginx/alexis-blog.fr_error.log;
access_log /var/log/nginx/alexis-blog.fr_access.log;
client_max_body_size 100M;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
pagespeed on;
pagespeed FileCachePath "/var/cache/ngx_pagespeed/";
pagespeed RewriteLevel OptimizeForBandwidth;
pagespeed EnableFilters collapse_whitespace;
pagespeed EnableFilters inline_css;
pagespeed EnableFilters inline_images;
pagespeed EnableFilters recompress_images;
pagespeed EnableFilters convert_to_webp_lossless;
pagespeed EnableFilters convert_jpeg_to_webp;
pagespeed EnableFilters insert_dns_prefetch;
pagespeed EnableFilters prioritize_critical_css;
pagespeed EnableFilters combine_css;
pagespeed EnableFilters combine_javascript;
#This filter is likely to cause problems for loading your web pages.
#pagespeed EnableFilters defer_javascript;
location ~ ".pagespeed.([a-z].)?[a-z]{2}.[^.]{10}.[^.]+" {
add_header "" "";
}
location ~ "^/pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
listen [::]:443 ssl http2 ipv6only=on; # managed by Certbot
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/alexis-guay.fr/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/alexis-guay.fr/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.alexis-guay.fr) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = alexis-guay.fr) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name alexis-guay.fr www.alexis-guay.fr;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment