[英]Nginx Browser Caching is not allowed here
I tried to insert browser expire dates for all static types in nginx. 我试图在nginx中为所有静态类型插入浏览器过期日期。 I copy this:
我复制一下:
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 365d;
}
before "server_tokens off;" 在“server_tokens off;”之前 at my:
在我:
/etc/nginx/nginx.conf
and get this error: 并得到此错误:
nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:54
Anyone could help me? 有人可以帮帮我吗?
Here the current working config! 这里是当前的工作配置!
#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;
}
All based on a Ubuntu 12.04 VPS 全部基于Ubuntu 12.04 VPS
Ensure your location
block is inside the server
or location
block. 确保您的
location
块位于server
或location
块内。
Source: http://nginx.org/en/docs/http/ngx_http_core_module.html#location 来源: http : //nginx.org/en/docs/http/ngx_http_core_module.html#location
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.