`
cfan_haifeng
  • 浏览: 120069 次
  • 性别: Icon_minigender_1
  • 来自: 郑州
社区版块
存档分类
最新评论

nginx: [emerg] "proxy_cache_path" directive is not allowed here..

阅读更多

由于需要解决nginx + tomcat 导致session丢失的问题,使用了proxy_cookie_path,但不幸的是总是出现上述错误。我当初是用yum -y remove nginx CentOS release 6.5 (Final)下安装的,执行nginx -v 发现版本为:nginx version: nginx/1.0.15。而当时(20151)的稳定版本是nginx-1.6.2 ,所以决定换它来试试。

先执行yum -y remove nginx  ,卸载了原先安装的nginx/1.0.15。然后按照如下两个文档进行编译安装即可:

http://blog.aboutc.net/nginx/62/compile-and-install-nginx-on-linux

http://www.jb51.net/article/49479.htm

 

结论:

  1. 该错误应该是版本太低造成的
  2. configure脚本中无需添加--with-http_proxy_module 或者--with-http_rewrite_module,实际证明nginx-1.6.2 本身就支持,加了反而在出错,如 ./configure: error: invalid option "--with-http_rewrite_module" 

 

 

相关参考:

 

官网:http://nginx.org/

nginx + tomcat 导致session丢失的问题:http://www.thinksaas.cn/group/topic/277531/

centos下编译安装nginx|configure参数对照列表:http://www.cnblogs.com/y0umer/archive/2013/04/28/3050158.html 

nginx启动,重启,关闭命令:http://www.cnblogs.com/derekchen/archive/2011/02/17/1957209.html

分享到:
评论
1 楼 cfan_haifeng 2015-03-02  
另外,我这里还有一种情况,需要加上 proxy_set_header X-Forwarded-Host $server_name;其中$server_name就是域名,然后再从代理指向的jsp中获得信息,如:
String siteUrl = request.getScheme() + "://" + request.getHeader("x-forwarded-host");

相关推荐

Global site tag (gtag.js) - Google Analytics