Location directive in nginx configuration
Posted
by
ryan
on Server Fault
See other posts from Server Fault
or by ryan
Published on 2012-06-20T19:28:52Z
Indexed on
2012/06/20
21:17 UTC
Read the original article
Hit count: 324
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.
© Server Fault or respective owner