• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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