Nginx简易配置文件(三)(文件缓存)
server {
listen 80;
listen 443 ssl;
server_name user.17.net userapi.17.net;
access_log logs/user/access.log main;
error_log logs/user/error.log;
ssl_certificate /usr/local/nginx/ssl/17track.crt;
ssl_certificate_key /usr/local/nginx/ssl/17track.key;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_protocols SSLv3 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-SHA384:AES256-SHA256:RC4:HIGH:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!AESGCM;
ssl_prefer_server_ciphers on;
location / {
# if ( $scheme ~* ^http$ ) {
# rewrite ^(/.*)$ https://$host$1 break;
# }
if ( $host ~* ^user\. ) {
proxy_pass http://cluster_user;
}
if ( $host ~* ^userapi\. ) {
proxy_pass http://cluster_userapi;
}
set $no_cache '';
set $cache_key '';
access_by_lua "
ngx.var.no_cache = '0'
ngx.var.cache_key=ngx.var.host ..ngx.var.uri
if string.find(ngx.var.uri, '^/res/') then
local newargs=ngx.var.args
if not newargs then
newargs=''
end
ngx.var.cache_key=ngx.var.host ..ngx.var.uri ..ngx.var.is_args ..newargs
end
if ngx.var.http_accept_encoding == nil then
local newargs1=ngx.var.args
local newargs2='/ungzip'
ngx.var.cache_key=ngx.var.host ..ngx.var.uri ..newargs2
if string.find(ngx.var.uri, '^/res/') then
if not newargs1 then
newargs1=''
end
ngx.var.cache_key=ngx.var.host ..ngx.var.uri ..ngx.var.is_args ..newargs1 ..newargs2
end
end
";
header_filter_by_lua "
if ngx.status ~= 200 then
ngx.var.no_cache = '1'
end
";
proxy_cache_key $cache_key;
proxy_cache_bypass $no_cache;
proxy_no_cache $no_cache;
proxy_cache cache_one;
proxy_cache_valid 200 304 10m;
proxy_cache_valid 301 302 1m;
proxy_cache_valid any 1m;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
add_header Nginx-Cache $upstream_cache_status;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Nginx简易配置文件(三)(文件缓存)的更多相关文章
- nginx实现动态/静态文件缓存(week4_day1_part2)-技术流ken
nginx实现静态文件缓存实战 1.nginx静态文件缓存 如果要熟练使用nginx来实现文件的缓存,那下面的几个指令你必须要牢记于心 指令1:proxy_cache_path 作用:设置缓存数据的相 ...
- Nginx简易配置文件(二)(反向代理)
user nobody nobody; worker_processes 4; error_log logs/error.log; pid logs/nginx.pid; events { use e ...
- Nginx简易配置文件(一)(静态页面及PHP页面解析)
user nobody nobody; worker_processes 4; error_log logs/error.log; pid logs/nginx.pid; events { use e ...
- nginx vhosts rewrite 独立文件的方式出现
[root@web01 /]# cat /app/server/nginx/conf/nginx.conf user www www; worker_processes ; error_log /ap ...
- docker+fastdfs+nginx 实现分布式大文件存储系统以及视频缓存播放
废话不多说,直接开撸 首先是一些准备工作: 1.关闭防火墙 service iptables stop --- fastdfs虽然在docker部署,但是使用的是主机网络,所以关闭防火墙. 2 下载 ...
- nginx静态文件缓存的解决方案
nginx的一大功能就是完成静态资源的分离部署,减轻后端服务器的压力,如果给这些静态资源再加一级nginx的缓存,可以进一步提升访问效率. 第一步:添加nginx.conf的http级别的缓存配置 # ...
- 高性能Web服务器Nginx的配置与部署研究(12)应用模块之Memcached做文件缓存时压缩引起的问题
在上一篇文章中,提到的Nginx的Memcached模块应用场景,主要是作为文件缓存.然后就发现了一个问题,当以字节数组方式缓存较大的文件时,缓存数据会被压缩,从而在读取的时候出现问题. (本文欢迎转 ...
- Linux服务之nginx服务篇五(静态/动态文件缓存)
一.nginx实现静态文件缓存实战 1.nginx静态文件缓存 如果要熟练使用nginx来实现文件的缓存,那下面的几个指令你必须要牢记于心 (1)指令1:proxy_cache_path 作用:设置缓 ...
- 01_Nginx安装,nginx下部署项目,nginx.conf配置文件修改,相关文件配置
1.下载Nginx,进入Nginx下载地址:http://nginx.org/ 点击nginx-1.8.0,进入:http://nginx.org/en/download.html,下载文件: ...
随机推荐
- Linux iptables配置错误导致ORA-12535 & ORA-12170
实验环境: 操作系统 : Red Hat Enterprise Linux Server release 5.7 (Tikanga) 数据库版本: Oracle Databa ...
- 数据库服务器改名导致Reporting Service不可用的案例
案例环境: 操作系统版本 : Windows Server 2012 R2 Standard 数据库版本 : SQL Server 2012 Standard Edition ...
- RAC异机恢复
RAC异机恢复PDCL到PFCL: PNCL:RAC+ASM ,product env db name:PNCL instance:PDCL1 PDCL2 PFCL:RAC+ASM ,perf ...
- 烂泥:haproxy学习之https配置
本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb. 在前一段时间,我写了几篇有关学习haproxy的文章.今天我们再来介绍下haproxy ...
- [python]爬虫学习(一)
要学习Python爬虫,我们要学习的共有以下几点(python2): Python基础知识 Python中urllib和urllib2库的用法 Python正则表达式 Python爬虫框架Scrapy ...
- hadoop.home.dir is not set
今天遇到一个错误,JAVA堆栈如下: 是在获取文件系统对象的时候出错,没有找到环境变量 HADOOP_HOME or hadoop.home.dir ,但是在本地一直没有重现这个问题. 这个问题是一个 ...
- 【2016-11-7】【坚持学习】【Day22】【Oracle 分页查询】
方法1: select * from (select rownum rn, temp.* from ( +sqlText+ ) temp ) where rn > "+ start + ...
- BZOJ 1061: [Noi2008]志愿者招募 [单纯形法]【学习笔记】
1061: [Noi2008]志愿者招募 Time Limit: 20 Sec Memory Limit: 162 MBSubmit: 3975 Solved: 2421[Submit][Stat ...
- 初识Quartz(入门案例)+常用的Cron表达式
1.Quartz架构图 1.实体层 package cn.happy.entity; //1. public class Plan { //时间 private String date; //任务 p ...
- 转: Protobuf 的 proto3 与 proto2 的区别
Protobuf 的 proto3 与 proto2 的区别 On 2015-07-17 19:16:00 By Soli Protobuf 的 proto3 与 proto2 的区别 这是一 ...