nginx + ssi +远程uri访问不起作用

时间:2010-04-14 03:18:35

标签: nginx ssi

我有一个设置,我的nginx在apache + PHP后面。

我的PHP应用程序在memcache中缓存一些页面,这些页面由nginx直接访问,除了在Nginx中使用SSI构建的一些动态部分。

我遇到的第一个问题是nginx没有尝试将memcache用于ssi URI。

<!--# include virtual="/myuser" -->

所以我想如果我强迫它使用完整的URL,那就可以了。

<!--# include virtual="http://www.example.com/myuser" -->

但是在日志文件(包括nginx和apache)中,我可以看到在url的开头添加了斜杠

http ssi filter "/http://www.example.com/myuser"

在SSI模块的源代码中,我看到一个似乎被添加的PREFIX,但我真的可以告诉我是否可以禁用它。

有人遇到过这个问题吗? Nginx版本:Ubuntu Karmic 64bits上的0.7.62

非常感谢

2 个答案:

答案 0 :(得分:16)

可以配置nginx以包含远程URL,尽管您无法直接在SSI指令中引用它们。在站点配置中,使用本地路径创建位置,并指定指向所需位置的远程位置。例如:

server {
....
  location /remote {
    proxy_pass @long_haul; # or use "try_files" to provide fallback
  }

  location @long_haul {
    proxy_pass http://porno.com;
  }
....
}

并在服务的html中使用include指令引用/ remote path:

  <!--# include virtual="/remote/rest-of-url&and=parameters" -->

请注意,您可以自定义使用变量和regexp进一步传递的URL。例如:

  location ~/remote(.+) {
    proxy_pass @long_haul$1?$args;
  }

答案 1 :(得分:2)

相关问题