Skip to content

Instantly share code, notes, and snippets.

@rodde177
Forked from molotovbliss/Caddyfile
Created April 8, 2019 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodde177/f7be916058c9048eb818d31c510c9b7b to your computer and use it in GitHub Desktop.
Save rodde177/f7be916058c9048eb818d31c510c9b7b 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
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment