• Introducing WebPros Cloud - a fully managed infrastructure platform purpose-built to simplify the deployment of WebPros products !  WebPros Cloud enables you to easily deliver WebPros solutions — without the complexity of managing the infrastructure.
    Join the pilot program today!
  • Support for BIND DNS has been removed from Plesk for Windows due to security and maintenance risks.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS.

Issue Nginx add_header not woking inside locations

bernhardh86

Basic Pleskian
I am now trying around since hours, but I can't get in work.

On apache&nginx settings page, I have turned off proxy mode and the "static files direct" option. Then I have added this (and only this) additional config to the textarea:

```
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf|webp)$ {
access_log off;
expires 365d;
add_header 'Cache-Control' "public, max-age=365";
}
```

This should add the "Cache-Control" setting on all static media files and it is based on this: Additional nginx directives are not applied when nginx proxy mode is disabled in Plesk

But it doesn't work. Chrome doesn't show it.

Then I have tried to remove everything but the `add_header ..` line:

```
add_header 'Cache-Control' "public, max-age=365";
```

And now its working, but of course for all files, not only media files.

I have even tried this:

```
location / {
add_header 'Cache-Control' "public, max-age=365";
}
```

and it is not adding the header.


Anybody an idea, why its not working as expected.
 
Ok. It looks like my problem was, that I used the "password protected directory" function, which breaks some nginx config features. Turning it off and protecting the folders manually works without problems
 
Back
Top