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简易配置文件(三)(文件缓存)的更多相关文章

  1. nginx实现动态/静态文件缓存(week4_day1_part2)-技术流ken

    nginx实现静态文件缓存实战 1.nginx静态文件缓存 如果要熟练使用nginx来实现文件的缓存,那下面的几个指令你必须要牢记于心 指令1:proxy_cache_path 作用:设置缓存数据的相 ...

  2. Nginx简易配置文件(二)(反向代理)

    user nobody nobody; worker_processes 4; error_log logs/error.log; pid logs/nginx.pid; events { use e ...

  3. Nginx简易配置文件(一)(静态页面及PHP页面解析)

    user nobody nobody; worker_processes 4; error_log logs/error.log; pid logs/nginx.pid; events { use e ...

  4. nginx vhosts rewrite 独立文件的方式出现

    [root@web01 /]# cat /app/server/nginx/conf/nginx.conf user www www; worker_processes ; error_log /ap ...

  5. docker+fastdfs+nginx 实现分布式大文件存储系统以及视频缓存播放

    废话不多说,直接开撸 首先是一些准备工作: 1.关闭防火墙 service iptables stop --- fastdfs虽然在docker部署,但是使用的是主机网络,所以关闭防火墙. 2  下载 ...

  6. nginx静态文件缓存的解决方案

    nginx的一大功能就是完成静态资源的分离部署,减轻后端服务器的压力,如果给这些静态资源再加一级nginx的缓存,可以进一步提升访问效率. 第一步:添加nginx.conf的http级别的缓存配置 # ...

  7. 高性能Web服务器Nginx的配置与部署研究(12)应用模块之Memcached做文件缓存时压缩引起的问题

    在上一篇文章中,提到的Nginx的Memcached模块应用场景,主要是作为文件缓存.然后就发现了一个问题,当以字节数组方式缓存较大的文件时,缓存数据会被压缩,从而在读取的时候出现问题. (本文欢迎转 ...

  8. Linux服务之nginx服务篇五(静态/动态文件缓存)

    一.nginx实现静态文件缓存实战 1.nginx静态文件缓存 如果要熟练使用nginx来实现文件的缓存,那下面的几个指令你必须要牢记于心 (1)指令1:proxy_cache_path 作用:设置缓 ...

  9. 01_Nginx安装,nginx下部署项目,nginx.conf配置文件修改,相关文件配置

     1.下载Nginx,进入Nginx下载地址:http://nginx.org/ 点击nginx-1.8.0,进入:http://nginx.org/en/download.html,下载文件: ...

随机推荐

  1. SqlException 当前命令发生了严重错误 应放弃任何可能产生的结果

    今天在信息发布功能时出现了一个怪异的错误(时而出错,时而不会): System.Data.SqlClient.SqlException: 当前命令发生了严重错误.应放弃任何可能产生的结果. >& ...

  2. Python之路:堡垒机实例

    堡垒机前戏 开发堡垒机之前,先来学习Python的paramiko模块,该模块机遇SSH用于连接远程服务器并执行相关操作 SSHClient 用于连接远程服务器并执行基本命令 基于用户名密码连接: 1 ...

  3. Oracle转移数据表空间存储位置

    问题描述:Oracle表空间创建到了C盘,发现C盘的空间不够,现在将表空间的文件转移到D盘下. 操作方法: 1. 先登录sqlplus,登录用户.在cmd中输入:sqlplus /nologSQL&g ...

  4. MySQL 复制表

    MySQL 复制表 如果我们需要完全的复制MySQL的数据表,包括表的结构,索引,默认值等. 如果仅仅使用CREATE TABLE ... SELECT 命令,是无法实现的. 本文将为大家介绍如何完整 ...

  5. mysql 常用sql

    1.查询数据库.表的情况 show engines; #数据库的存储引擎show create TABLE User_Base_Info;#显示create table的sql语句show table ...

  6. 对iOS后台模式最多10分钟运行时间的进一步理解

    在app进入后台时,系统初始默认是只有10s的处理时间,但如果10s不够,我们可以主动申请,网上流传最多的一个说法是10分钟. 但这种说法有个前提: 那就是iOS7之前,是这样 但从iOS7开始,我们 ...

  7. apache ab测试命令详解

    这篇文章主要介绍了apache性能测试工具ab使用详解,需要的朋友可以参考下   网站性能压力测试是服务器网站性能调优过程中必不可缺少的一环.只有让服务器处在高压情况下,才能真正体现出软件.硬件等各种 ...

  8. android Dialog实例

    Dialog类 public class DialogUtil { public static Dialog EditDialog(Activity context,View view){ final ...

  9. [转]NET Core中实现一个Token base的身份认证

    本文转自:http://www.cnblogs.com/Leo_wl/p/6077203.html 注:本文提到的代码示例下载地址> How to achieve a bearer token ...

  10. Azure HDInsight 和 Spark 大数据实战(一)

    What is HDInsight? Microsoft Azure HDInsight 是基于 Hortonoworks Data Platform (HDP) 的 Hadoop 集群,包括Stor ...