Location directive in nginx configuration
- by ryan
I have an nginx server setup to act as a fileserver. I want to set the expires directive on images. This is how a part of my config file looks like.
http {
include /etc/nginx/mime.types;
access_log /var/log/nginx/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
tcp_nodelay on;
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
location ~* \.(ico|jpg|jpeg|png)$ {
expires 1y;
}
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
I get the following error when I reload config - "Location directive not allowed here".
Can someone tell me what the right syntax for this is?
Thanks in advance.
EDIT : Found the answer myself. Added it in a comment. Closing this.