Skip to content

Wiki - nginx configuration update #789

@chyl

Description

@chyl

I think rewrite rule in Wiki for nginx configuration is not accurate in static section.

There is a generated JS file which is responsible for adminhtml dropdown menus etc. With this rule:

 # Rewrite magento2 static files
 location /pub/static {
         rewrite ^/pub/static/(.*)$ /pub/static.php?resource=$1? last;
 }

instead of file I had this warning:

Unable to resolve the source file for '_requirejs/_view/backend/en_US/requirejs-config.js'
#0 /Users/***/Sites/magento2/lib/internal/Magento/Framework/App/StaticResource.php(127): Magento\Framework\View\Asset\File->getSourceFile()
#1 /Users/***/Sites/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(263): Magento\Framework\App\StaticResource->launch()
#2 /Users/***/Sites/magento2/pub/static.php(31): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\StaticResource))
#3 {main}

With handler based configuration for nginx i suggest to change rule to this:

location /pub/static {
     try_files $uri $uri/ @static;
}

location @static {
      rewrite ^/pub/static/(.*)$ /pub/static.php?resource=$1? last;
}

I think this is a proper way for serving static files according to https://wiki.magento.com/display/MAGE2DOC/Static+View+Files+Processing

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions