Skip to content

Instantly share code, notes, and snippets.

@molotovbliss
Created August 15, 2018 22:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save molotovbliss/f93d29d503a8811636e219e01dbf2c87 to your computer and use it in GitHub Desktop.
Save molotovbliss/f93d29d503a8811636e219e01dbf2c87 to your computer and use it in GitHub Desktop.
Caddyfile for Magento 2.2.x+ for Caddy web server
# source: https://caddy.community/t/using-caddy-on-a-fresh-magento-2-2-3-ce-install/3708/8
https://example.com {
root /var/www/magento2/pub
gzip {
ext .txt .css .less .js .jsonp .json .xml .rss .svg .svgz .html
level 6
min_length 1100
}
tls webmaster@example.com
log stdout
fastcgi / unix:/run/php-fpm/php-fpm.sock php {
root /var/www/magento2/pub
index index.php
connect_timeout 600s
read_timeout 600s
ext .php .html .js .css .less .ico
}
errors /var/log/caddy/errors.log
push
mime {
.txt text/plain
.css text/css
.less text/css
.js application/javascript
.jsonp text/javascript
.json application/json
.xml text/xml
.rss application/xml+rss
.svg image/svg+xml
.svgz image/svg+xml
}
internal /media/customer/
internal /media/downloadable/
internal /media/import/
rewrite {
r ^/media/\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$
to {path} {path}/ /get.php /get.php?{query}
}
header /media X-Frame-Options "SAMEORIGIN"
rewrite {
r ^/static/(version\d*/)?(.*)$
to /static/{2}
}
header /static X-Frame-Options "SAMEORIGIN"
rewrite {
to {path} {path}/ /index.php /index.php?{query}
}
header / {
X-Content-Type-Options "nosniff"
}
expires {
match ^/static/\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ 1y
match ^/static/\.(zip|gz|gzip|bz2|csv|xml)$ 0s
match ^/media/\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ 1y
match ^/media/\.(zip|gz|gzip|bz2|csv|xml)$ 0s
}
}
@nopenopenope
Copy link

This is for Caddy v1, not for Caddy v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment