---
title: "nginx: [emerg] \"proxy_cache_path\" directive is not allowed here.."
author: "cfan_haifeng"
date: "2015-01-07T14:40:15Z"
tags: []
categories: ["互联网"]
slug: "nginx-emerg-proxy-cache-path-directive-is-not-allowed-here"
draft: false
lastmod: "2015-01-07T14:28:29Z"
id: 2173096
url: "https://sunfish.iteye.com/blog/2173096"
---

由于需要解决nginx + tomcat 导致session丢失的问题，使用了proxy\_cookie\_path，但不幸的是总是出现上述错误。我当初是用yum -y remove nginx 在CentOS release 6.5 (Final)下安装的，执行nginx -v 发现版本为：nginx version: nginx/1.0.15。而当时(2015年1月)的稳定版本是[nginx-1.6.2](http://nginx.org/en/download.html) ,所以决定换它来试试。

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

[http://blog.aboutc.net/nginx/62/compile-and-install-nginx-on-linux](http://blog.aboutc.net/nginx/62/compile-and-install-nginx-on-linux)

[http://www.jb51.net/article/49479.htm](http://www.jb51.net/article/49479.htm)

 

结论：

1. 该错误应该是版本太低造成的
2. configure脚本中无需添加--with-http\_proxy\_module 或者--with-http\_rewrite\_module，实际证明[nginx-1.6.2](http://nginx.org/en/download.html) 本身就支持，加了反而在出错，如 ./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](http://www.cnblogs.com/derekchen/archive/2011/02/17/1957209.html)