• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion
  • Inviting everyone to the UX test of a new security feature in the WP Toolkit
    For WordPress site owners, threats posed by hackers are ever-present. Because of this, we are developing a new security feature for the WP Toolkit. If the topic of WordPress website security is relevant to you, we would be grateful if you could share your experience and help us test the usability of this feature. We invite you to join us for a 1-hour online session via Google Meet. Select a convenient meeting time with our friendly UX staff here.

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