代码之家  ›  专栏  ›  技术社区  ›  stunti

nginx+ssi+远程URI访问不工作

  •  1
  • stunti  · 技术社区  · 16 年前

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

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

    我遇到的第一个问题是nginx没有尝试为ssi-uri使用memcache。

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

    所以我想如果我强迫它使用一个完整的URL,它就会做到。

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

    但是在日志文件(nginx和apache)中,我可以看到在URL的开头添加了一个斜杠。

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

    在ssi模块的源代码中,我看到了一个似乎要添加的前缀,但我可以确定是否可以禁用它。

    有人知道这个问题吗? nginx版本:Ubuntu Karmic 64位0.7.62

    谢谢

    2 回复  |  直到 15 年前
        1
  •  2
  •   Lipingtababa    16 年前

    这跟nginx没什么关系,你就是做不到。SSI不接受远程URI。只能指定本地文件路径。

    见 http://en.wikipedia.org/wiki/Server_Side_Includes

        2
  •  16
  •   Petr Gladkikh    15 年前

    你 可以 配置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 virtual="/remote/rest-of-url&and=parameters" -->
    

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

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