Vue.js / Nginx / Node.js - 413 请求实体太大

Vue.js / Nginx / Node.js - 413 Request Entity Too Large

我的前端是在 Vue.js 上制作的,并且是 运行 在生产中的 nginx 上。我的 nginx.conf 看起来像:

server {
    listen                  80;
    server_name             localhost;

    root                    /usr/share/nginx/html;
    index                   index.html index.htm;

    client_max_body_size    100M;

    # added for VueRouter
    location / {
        try_files $uri $uri/ /index.html;
    }
}

在 Node.js 应用程序中,我有这个端点使用 multer 接受文件:

// 100 MB
const upload = multer({ storage, limits: { fileSize: 100 * 1024 * 1024 } })

const router = express.Router()
router.post('/create', upload.single('file'), ImageController.create)

同样在 app.js 中,我将 bodyParser 设置为 100 MB:

const app = express()

// Middleware
app.use(bodyParser.urlencoded({ limit: '100mb', extended: true, parameterLimit: 100000 }))
app.use(bodyParser.json({ limit: '100mb' }))

但我仍然得到错误

413 Request Entity Too Large

我是不是漏掉了什么?

我设法修复了它,问题与我预期的完全不同。在我的 VPS 中,我创建了 docker 网络 nginx-proxy 到 link 到不同域名的不同端口。我也必须将 client_max_body_size 100M; 添加到该容器的 nginx.conf!