免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3131 | 回复: 1
打印 上一主题 下一主题

[Web] 请教nginx不能缓存默认首页的问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-30 17:12 |只看该作者 |倒序浏览
各位老大我用nginx做的反向代理,为了提高性能我想让nginx直接用缓存返回给客户,我配置后保存 cache后发现,访问的网站图版什么的都能正确保存,但没办法保存默认首页.
如下:后站服务器网站默认页为index.htm

http://www.test.com    到cache下检查就没有缓存index.htm文件。
http://www.test.com/index.htm    到cache下检查成功缓存index.htm文件。
也就是nginx好像必需要不能取得后端服务器默认主页的文件名所以不能缓存,但如果不能缓存首页的话我用if ( !-e $request_filename)判断来使用缓存文件就会产生错误。请知道的老大帮助看看!

nginx配置文件如下:
user  nobody nobody;
worker_processes  1;
pid        logs/nginx.pid;

worker_rlimit_nofile 1024;
events {
    use epoll;
    worker_connections  1024;
}

http {
         include             mime.types;
         default_type    application/octet-stream;
         #charset  gb2312;
         server_names_hash_bucket_size 256;
         client_header_buffer_size 256k;
         large_client_header_buffers 4 256k;
         client_max_body_size             50m;
         client_body_buffer_size        256k;
         client_header_timeout     3m;
         client_body_timeout 3m;
         send_timeout             3m;
         sendfile on;
         tcp_nopush         on;
         tcp_nodelay    on;
         keepalive_timeout 120;


    upstream test_com {
        server 192.168.1.1:8080 weight=3;
    }

server {
        listen         80 default;
        server_name     www.test.com www.test.com.cn;
        index index.htm index.html index.php;
        access_log  logs/test_com.access.log;
        proxy_store on;
        proxy_store_access      user:rw  group:rw  all:r;
        proxy_temp_path cache/proxy;
        proxy_redirect off;
        location / {
                        root cache/proxy/$host;
                        #if ( !-e $request_filename) {
                        proxy_pass      http://test_com;
                        #}
                        proxy_redirect        off;
                        proxy_set_header        Host $http_host;
                        proxy_set_header        X-Real-IP $remote_addr;
                        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                        proxy_set_header        X-Is-EDU  0;
                        proxy_next_upstream error;
                        client_max_body_size 50m;
                        client_body_buffer_size 256k;
                        proxy_connect_timeout 10;
                        proxy_send_timeout 60;
                        proxy_read_timeout 60;
                        proxy_buffer_size 4k;
                        proxy_buffers 8 128k;
                        proxy_busy_buffers_size 128k;
                        proxy_temp_file_write_size 128k;
                        }
        }

[ 本帖最后由 thxyh 于 2009-12-30 17:13 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2010-05-31 18:21 |只看该作者
顶~~~~ 我也碰到这个问题
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP