[英]Nginx Browser Caching is not allowed here
我试图在nginx中为所有静态类型插入浏览器过期日期。 我复制一下:
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
在“server_tokens off;”之前 在我:
/etc/nginx/nginx.conf
并得到此错误:
nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:54
有人可以帮帮我吗?
这里是当前的工作配置!
#user nginx;
worker_processes 1;
#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
#pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx/access.log main;
sendfile off;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;
# output compression saves bandwidth
gzip on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;
# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/07/25/nginx-gzip-ssl.html
gzip_buffers 16 8k;
# Disable gzip for certain browsers.
gzip_disable “MSIE [1-6].(?!.*SV1)”;
server_tokens off;
include /etc/nginx/conf.d/*.conf;
}
全部基于Ubuntu 12.04 VPS
确保您的location
块位于server
或location
块内。
来源: http : //nginx.org/en/docs/http/ngx_http_core_module.html#location
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.