Skip to content

Instantly share code, notes, and snippets.

@NatemcM
Last active August 6, 2020 07:25
Show Gist options
  • Save NatemcM/5934398cc1de920d3a65e1ca50f71eba to your computer and use it in GitHub Desktop.
Save NatemcM/5934398cc1de920d3a65e1ca50f71eba to your computer and use it in GitHub Desktop.
MODX Cloud NGINX Config
# Redirect to www and force HTTPS
#add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
if ($scheme != "https") {
rewrite ^ https://$host$uri permanent;
}
# www.mydomain.com -> mydomain.com
# if ($host = "www.mydomain.com") {
# return 301 $scheme://mydomain.com$request_uri;
# }
# mydomain.com -> ww.mydomain.com
# if ($host = "mydomain.com") {
# return 301 $scheme://www.mydomain.com$request_uri;
# }
# Multi context asset redirect
# location ~ ^/(en|th|es) {
# # redirect favicon.ico and assets/* requests to site root
# rewrite ^/(en|th|es)/(favicon.ico|assets.*)$ /$2 redirect;
# # MODX rewrite
# try_files $uri $uri/ @modx-rewrite;
# }
# GZIP and cache
# GZIP
gzip on;
gzip_comp_level 5;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Disable for IE < 6 because there are some known problems
gzip_disable "MSIE [1-6].(?!.*SV1)";
# Add a vary header for downstream proxies to avoid sending cached gzipped files to IE6
gzip_vary on;
location ~* \.(?:ico|css|js|jpe?g|png|webp|gif|svg|pdf|mov|mp4|mp3|woff)$ {
expires 365d;
add_header Pragma public;
add_header Cache-Control "public";
gzip_vary on;
}
# MODX Friendly URLs
location / {
try_files $uri $uri/ @modx-rewrite;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment