全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 4541|回复: 26

nginx前端+apache后端——这样配置有没有效果?

[复制链接]
发表于 2011-12-1 16:05:18 | 显示全部楼层 |阅读模式
准备也尝试下使用nginx前端+apache后端

关于区别动态和静态文件时,我看很多人都是这样配置的:
                location ~ .*\.(jpeg|jpg|gif|png|bmp|ico|js|css|swf)$ {
                        expires      12d;
                }

我现在在里面加个html,也就是变成这样:
                location ~ .*\.(html|jpeg|jpg|gif|png|bmp|ico|js|css|swf)$ {
                        expires      12d;
                }

是不是脱裤子放屁?

因为我现在访问一个不存在的html文件,浏览器提示:

Not Found
The requested URL /index2.html was not found on this server.

这个明显是apache处理返回的结果
发表于 2011-12-1 16:05:39 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2011-12-1 16:08:44 | 显示全部楼层
访问量大的话很有效果。
发表于 2011-12-1 16:09:44 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2011-12-1 16:10:19 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| 发表于 2011-12-1 16:14:36 | 显示全部楼层
原帖由 uconny 于 2011-12-1 16:10 发表
我们的网站是用nginx+php
http://www.52vhost.com/


滚吧
发表于 2011-12-1 16:19:54 | 显示全部楼层
nginx+apache起作用最大的一个地方就是try_files这个
 楼主| 发表于 2011-12-1 16:23:23 | 显示全部楼层
原帖由 Kvm 于 2011-12-1 16:19 发表
nginx+apache起作用最大的一个地方就是try_files这个


我是这样设置的,没办法,因为要用apache的伪静态

                location ~ \.php$ {
                        proxy_pass http://127.0.0.1:81;
                        include proxy_params;
                }

                location / {
                        try_files $uri $uri/ @apache;
                }

                location @apache {
                        proxy_pass http://127.0.0.1:81;
                        include proxy_params;
                }

                location /status {
                        stub_status on;
                        access_log   off;
                }

                location ~ .*\.(html|jpeg|jpg|gif|png|bmp|ico|js|css|swf)$ {
                        expires      12d;
                }


现在加了html后缀优先后,访问不存在的html页面,果然提示:

404 Not Found
nginx/1.0.10

就这么干了
发表于 2011-12-1 16:26:05 | 显示全部楼层
完全没这个必要
 楼主| 发表于 2011-12-1 16:26:57 | 显示全部楼层
原帖由 fw2you 于 2011-12-1 16:26 发表
完全没这个必要


试验证明有必要
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-14 06:06 , Processed in 0.070551 second(s), 9 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表