Magento 2 & Lighttpd configuration

Reprise des activités Magento avec sa nouvelle version 2.1.4 et sa configuration Lighttpd.
Cette configuration se base largement sur celle fournie par Anton Samuelsson avec quelques ajustements dont la suppression du message d’avertissement de sécurité du backoffice.

# ==========================
# --- Magento 2 Lighttpd ---
# ==========================
#
# Magento  : 2.1.4
# Lighttpd : 1.4.43+git20161216-1
#
# Require "mod_access" module
#
# 2017.02.02 : Init (Based on Anton Samuelsson config. https://gist.github.com/freestream/)
# 2017.02.15 : Disable access to "/app/etc/config.php" (This remove backoffice warning)

server.modules += ("mod_access")

$HTTP["host"] =~ "^(magento2)" {
    server.document-root = "/var/www/magento2/"

    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"         => "default",

        # Unknown result. Both are currently broken.
        #
        # firebug
        # csv
        #
        #"MAGE_PROFILER"     => "firebug"
    )

    var.asset_allowed_img_ext   = "ico|gif|jpg|JPEG|jpeg|png|css|swf|pdf|ttf|woff2|woff|xml|wsdl|svg|otf|eot"
    var.asset_allowed_oth_ext   = "|js|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.redirect = (
        "^/pub/static/version([\d]+)/(.*)" => "/pub/static/$2"
    )

    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"] == "/app/etc/config.php" {
        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"
        )
    }

    accesslog.filename = "/var/log/lighttpd/magento2.access.log"
}

Les commentaires sont désactivés.