Hi George,
Thanks for the in-depth reply!
I’ve actually been working with magento in one form or another for about 8 years and even when we were working with 1.x, performance was always an issue.
When you say
I take it you have already attempted to run Magento 2.2 on Caddy?
In order to get to a point on a server where you can even install Magento, you have to have all the pre-reqs taken care of first. PHP, MySQL, Web Server.
My issue is that if you have already made it to this point, why cant you have a decent, working install that you can start setting up and configuring from within the admin panel?
I consider myself pretty technically inclined and with time can figure out pretty much anything, but I look at your post and all I see is about another week of research, messing around issues and configs and that much more of a delay before I can even start using it.
I really do appreciate the in depth response and will be looking into it, but I think that there might be an opportunity here where say a small business owner can come in, take a pre-configured Caddyfile, plug in their domain, un-comment additional settings if they want and get up and running with a fresh install quickly and painlessly.
I tell you what, I’d like a second opinion here. I have a “working” Caddyfile config that is doing AWESOME for me right now, as long as you install magento via cli. I havent gotten the web-setup to work yet, and theres still a lot left I have to figure out but if you know how to install Magento 2.2.3 via composer and have all your pre-requisites setup, I’d love to hear how the experience is for you vs setting up with Apache or Nginx.
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 ## Are there any restrictions here?
}
errors /var/log/caddy/errors.log ## Plan on expanding this out a bit more
push ## For now, I'm not sure if this is helping or hurting? or anything really at all?
# MIME Types used
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 links only, these paths are listed as Deny All
internal /media/customer/
internal /media/downloadable/
internal /media/import/
## Tried a couple different configurations and the web setup wizard would not work. I adjusted the root directive so it pointed to my docroot and could use some fresh ideas.
# rewrite {
# r ^/setup($|/)
# to {path} {path}/ ^/setup/index.php {uri} {uri}/ /index.php{uri}
# }
# header ^/setup/pub/ X-Frame-Options "SAMEORIGIN"
## I stopped messing with the update blocks because I couldnt figure out where within the code this actually existed. Besides in just the nginx.conf.sample file.
# rewrite {
# r ^/update($|/)
# to {path} {path}/ ^/update/index.php {uri} {uri}/ /index.php{uri}
# }
## Apparently it doesnt like my regex on the if lines, Guess im doing this wrong, any ideas?
rewrite {
# if {file} not_match ^/media/theme_customization/.*\.xml
r ^/media/\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$
# if {file} match ^/media/\.(zip|gz|gzip|bz2|csv|xml)$
to {path} {path}/ /get.php /get.php?{query}
}
header /media X-Frame-Options "SAMEORIGIN"
# header /media/\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ Cache-Control "public"
# header /media/\.(zip|gz|gzip|bz2|csv|xml)$ Cache-Control "no-store"
## Taking the Version number out actually works! Instead of setting 'php bin/magento config:set dev/static/sign 0' Not good having unversioned files floating around in cache?
rewrite {
r ^/static/(version\d*/)?(.*)$
to /static/{2}
}
## Yea, no worky here either. I have a feeling that some of these things have to be getting taken care of via one of ym other rewrites?
# rewrite {
# ext .ico .jpg .jpeg .png .gif .svg .js .css .swf .eot .ttf .otf .woff .woff2
# r ^/static/?(.*)$
# to /static.php?resource={1}
# }
# rewrite {
# ext .zip .gz .gzip .bz2 .csv .xml
# r ^/static/?(.*)$
# to /static.php?resource={1}
# }
## Can regex be used with the header directive? otherwise how would the headers here, and up higher in the file, accomplish what this is supposed to?
header /static X-Frame-Options "SAMEORIGIN"
# header /static/\.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ Cache-Control "public"
# header /static/\.(zip|gz|gzip|bz2|csv|xml)$ Cache-Control "no-store";
## Maybe I could get a little help with an explanation on this rewrite if possible please? Why does this work without the regex? Im a bit lost here.
rewrite {
# r (index|get|static|report|404|503|health_check)\.php$
to {path} {path}/ /index.php /index.php?{query}
}
header / {
X-Content-Type-Options "nosniff" ## Get around to adding making sure headers get set correctly
}
## How can you specify "off" for those files? or +1y or any of the other crazy things I've seen specified looking around?
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
}
}
Soooo… to recap. With the below configs, Magento 2.2.3 is up and running with no errors in my logs and pretty good performance.
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
}
}
Unfortunately I’m pretty sure that I’ve not configured everything in here correctly and the stuff thats commented out in the top example are a lot of what I still have questions on. @matt @Whitestrake Could use your input here on this conversion so far. Any ideas or suggestions?
Thanks!