---
title: "nginx 405 Not Allowed"
author: "chembo"
date: "2013-04-07T22:41:08Z"
tags: ["405", "nginx"]
categories: ["开源软件"]
slug: "nginx-405-not-allowed"
draft: false
lastmod: "2013-04-07T22:41:08Z"
id: 1843365
url: "https://chembo.iteye.com/blog/1843365"
---

这个错误的原因是：Apache、IIS、Nginx等绝大多数web服务器，都不允许静态文件响应POST请求，否则会返回“HTTP/1.1 405 Method not allowed”错误。 


```java
upstream static_backend {
    server localhost:80;
}

server {
    listen 80;

    # ...

    error_page 405 =200 @405;
    location @405 {
        root /srv/http;
        proxy_method GET;
        proxy_pass http://static_backend;
    }
}
```