Skip to content

Instantly share code, notes, and snippets.

@freestream
Created September 5, 2015 10:36
Show Gist options
  • Save freestream/5bc28cfc716d1f9132f2 to your computer and use it in GitHub Desktop.
Save freestream/5bc28cfc716d1f9132f2 to your computer and use it in GitHub Desktop.
Magento 2 lighttpd config
##
# Magento 2
##
$HTTP["host"] == "example.com" {
server.document-root = "/var/www/example/"
setenv.add-environment = (
# default Disables static file caching, provides verbose logging,
# automatic code compilation, enhanced debugging.
#
# developer Static file caching is enabled, automatic code
# compilation is enabled, exceptions are not displayed to
# the user; instead, exceptions are written to log files.
#
# production Exceptions are not displayed to the user, exceptions are
# written to logs only, and static files are not cached.
#
"MAGE_MODE" => "developer",
# Unknown result. Both are currently broken.
#
# firebug
# csv
#
#"MAGE_PROFILER" => "firebug"
)
var.asset_allowed_img_ext = "js|ico|gif|jpg|JPEG|jpeg|png|css|swf|pdf|ttf|woff2|woff|xml|wsdl|svg|otf|eot"
var.asset_allowed_oth_ext = "zip|gz|gzip|bz2|csv|xml|html|json"
expire.url = (
"/pub/(static|media)/.*\.(" + var.asset_allowed_img_ext + ")" => "access plus 7 days",
)
$HTTP["url"] =~ "/pub/(static|media)/.*\.(" + var.asset_allowed_img_ext + ")" {
setenv.add-response-header = (
"Cache-control" => "public, max-age=604800",
)
}
$HTTP["url"] =~ "/pub/(static|media)/.*\.(" + var.asset_allowed_oth_ext + ")" {
setenv.add-response-header = (
"Cache-control" => "no-store",
)
}
var.asset_allowed_ext += var.asset_allowed_img_ext
var.asset_allowed_ext += var.asset_allowed_oth_ext
var.asset_file_regex = "([-\w^&'@{}[\],$=!#().%+~\/ ])+(\.(" + var.asset_allowed_ext + "))(\?.*|)"
url.rewrite-if-not-file = (
"^/pub/static/(" + var.asset_file_regex + ")$" => "/pub/static.php?resource=$1",
"^/pub/media/(" + var.asset_file_regex + ")$" => "/pub/get.php?resource=$1",
"^/setup" => "/setup/index.php$1",
"(.*)" => "/index.php$1"
)
$HTTP["url"] =~ "^/app/|^/pub/media/customer/|^/pub/media/downloadable/|^/pub/errors/.*\.(xml|phtml)$" {
url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/pub/media/theme_customization/.*\.xml$" {
url.access-deny = ( "" )
}
$HTTP["url"] =~ "^/pub/cron\.php" {
url.access-deny = ( "" )
}
$HTTP["url"] =~ "(index|get|static|report|404|503)\.php$" {
setenv.add-environment = (
"PHP_FLAG" => "session.auto_start=off \n suhosin.session.cryptua=off"
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment