为什么我的 POST 请求无法通过 nginx 获得 proxy_passed 到我的 nodejs 应用程序?

Why do my POST requests not get proxy_passed by nginx to my nodejs app?

当我尝试从我的 Node.js 应用程序 POST 到 '/' 时,我收到 "directory index of "/home/" 被禁止,但我不确定为什么 nginx甚至尝试直接处理该请求?也许我误解了日志的输出。一些额外的调试表明 POST 根本没有对我的应用程序进行处理。

nginx 配置:

upstream appname {
    sever localhost:3000;
}

server {
    listen 80;
    error_log /etc/nginx/debug.log;
    rewrite_log on;
    root /home/;
    sever_name mydomain.name;

    location /appname/ {
        proxy_redirect off;
        proxy_pass http://appname/;
    }
}

如果我将我的位置设置为“/”,它当然可以完美运行。

在节点中它甚至没有达到

app.post('/', function(req, res){

但是

app.get('/', function(req, res){
    res.sendFile('index.html', {root: path.join(__dirname, '../views')})
});

按预期工作,returns 正确的资源。

为什么我的 POST 请求(貌似)没有通过代理?

看起来你的 nodejs 应用程序在 POST 之后重定向到 /home/,但没有意识到它已被代理并被 /appname/ 调用,你应该制作你的应用程序了解名称空间。并使其正确重定向到 /appname/home/