matomo-org / matomo-nginx

Nginx configuration for running Matomo
406 stars 121 forks source link

The libs|vendor|plugins|misc|node_modules rule breaks Matomo #64

Closed alimony closed 3 years ago

alimony commented 3 years ago

This rule:

location ~ ^/(libs|vendor|plugins|misc|node_modules) {
    deny all;
    return 403;
}

breaks my site completely. I have not narrowed it down yet because I don't want the site to be down while trying configs, but it seems like that rules denies JS files that are needed for Matomo to work.

Findus23 commented 3 years ago

Hi,

Are you using all rules as they are defined in the config?

One would expect that this ruleblocks a request to e.g./plugins/Morpheus/icons/dist/browsers/MF.png`, but it doesn't as it works together with the rule before:

https://github.com/matomo-org/matomo-nginx/blob/531f0c90197fab6ade1e9908e4d008108a948bf0/sites-available/matomo.conf#L71-L78

If a file matches this rule, nginx never considers the next one and the request will work (and therefore Matomo will work with this config). Only for these directories all requests are blocked: https://github.com/matomo-org/matomo-nginx/blob/531f0c90197fab6ade1e9908e4d008108a948bf0/sites-available/matomo.conf#L56

alimony commented 3 years ago

Ah, that must be it. I have all caching of static files set up on a higher level, so I skipped this one without analysing rule precedence enough. I will give it a try and update this issue later today.

Findus23 commented 3 years ago

Indeed ordering of Nginx is not trivial and it took me quite a few tries to come up with the order that works now.

alimony commented 3 years ago

Yes, including the additional block works for me, closing this issue.