nginx proxy_pass POST 404错误

我有nginx代理到一个应用程序服务器,具有以下configuration:

location /app/ { # send to app server without the /app qualifier rewrite /app/(.*)$ /$1 break; proxy_set_header Host $http_host; proxy_pass http://localhost:9001; proxy_redirect http://localhost:9001 http://localhost:9000; } 

对/ app的任何请求都会转到:9001,而默认网站托pipe在:9000。

GET请求正常工作。 但是每当我提交一个POST请求到/ app / any / post / url,它会导致一个404错误。 通过GET / app / any / post / url直接在浏览器中直接点击url,按预期的方式点击app服务器。

我在网上find了类似问题的其他人,并添加了

 proxy_set_header Host $http_host; 

但这并没有解决我的问题。

没有logging错误,访问日志如下:

 # For http://localhost:9000 (no proxying) 127.0.0.1 - - [08/Dec/2012:12:29:28 -0800] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4" # For http://localhost:9000/app/get/priorities (GET proxy) 127.0.0.1 - - [08/Dec/2012:12:32:17 -0800] "GET /app/get/priorities HTTP/1.1" 200 77 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4" # When posting to http://localhost:9000/app/create/priority: 127.0.0.1 - - [08/Dec/2012:12:33:50 -0800] "POST /app/create/priority/ HTTP/1.1" 404 188 "http://localhost:9000/form-test.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4" 

任何见解都表示赞赏。

谢谢。

完整configuration如下:

 server { listen 9000; ## listen for ipv4; this line is default and implied #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 root /home/scott/src/ph-dox/html; # root ../html; TODO: how to do relative paths? index index.html index.htm; # Make site accessible from http://localhost/ server_name localhost; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ /index.html; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } location /app/ { # rewrite here sends to app server without the /app qualifier rewrite /app/(.*)$ /$1 break; proxy_set_header Host $http_host; proxy_pass http://localhost:9001; proxy_redirect http://localhost:9001 http://localhost:9000; } location /doc/ { alias /usr/share/doc/; autoindex on; allow 127.0.0.1; allow ::1; deny all; } } 

我的不好,问题不是nginx,而是我的应用服务器。 我正在使用一个路由模块,要求我明确指定的请求方法,如果不是一个get,所以这就是为什么它会抛出一个404错误后,但不是当直接点击浏览器的url。