Expires functionality not working

Discussion in 'ISPConfig 3 Priority Support' started by Matthias Reich, Nov 15, 2019.

Tags:
  1. Hello,
    Following are my nginx directives:
    location / {
    try_files $uri $uri/ /index.php$is_args$args;
    }

    listen [::]:443 ssl http2 ipv6only=on;
    listen 443 ssl http2;

    location / {
    root /usr/share/rspamd/www/;
    try_files $uri @proxy;
    }

    location @proxy {
    proxy_pass http://127.0.0.1:11334;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    }

    location ~* \.(jpg|jpeg|gif|png|svg)$ {
    expires 365d;
    }

    location ~* \.(pdf|css|html|js|swf)$ {
    expires 10d;
    }

    However, it is not setting up an expiration time. I'm using the same expiration code for one of my other servers using ISPConfig and it is working there but not here. I've restarted the nginx server as well as the VPS but doesn't seem to help.

    Any suggestions?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Does your other server is proxing the requests as well? My guess is that's it related to the proxy.
     
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Try to put the:

    Code:
    location ~* \.(jpg|jpeg|gif|png|svg)$ {
    expires 365d;
    }
    
    location ~* \.(pdf|css|html|js|swf)$ {
    expires 10d;
    }
    in frong of the location / part. Maybe it helps. And did you check if the config you created was written to the website vhost file witout ending in an .err file? You have location / twice, so it might be that nginx rejected the whole config.
     
  4. Like this?

    listen [::]:443 ssl http2 ipv6only=on;
    listen 443 ssl http2;

    location ~* \.(pdf|css|html|js|swf|jpg|jpeg|gif|png|svg)$ {
    expires 365d;
    try_files $uri $uri/ /index.php$is_args$args;
    root /usr/share/rspamd/www/;
    try_files $uri @proxy;

    }

    location @proxy {
    proxy_pass http://127.0.0.1:11334;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    }
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    No, you can not have the same URI proxied and used locally in the web. Either you use / for rspamd or / for the cms that you seem to have installed in that site but you can not have both. How shall the webserver decide if a URL shall go to rspamd or to the local website? you can use:

    Code:
    location / {
     root /usr/share/rspamd/www/;
     try_files $uri @proxy;
    }
    
    location @proxy {
     proxy_pass http://127.0.0.1:11334;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header Host $http_host;
    }
    only if this is a dedicated website for rspamd without any other pages or website installed in it. But according to your config, you seem to have added this to an existing site and that can not work.
     
  6. Cool! That helps. Thank you.
     

Share This Page