Node.js 使ExpressJs识别基本路径

Node.js 使ExpressJs识别基本路径,node.js,express,Node.js,Express,我已经用express构建了一个小的nodejs应用程序。在我的本地机器上一切正常&当我将浏览器指向http://localhost:3000 但是现在我计划在其中一个域名上运行这个应用,比如说http://example.org 它运行在nginx上&它是一个php代码 但是,如何使我的express应用程序在example.org/nodeapp上正确运行该应用程序? 目前,它正在考虑将example.org作为我的应用程序的基本url&因此在我的路由中搜索nodeapp时抛出404。它应该

我已经用express构建了一个小的nodejs应用程序。在我的本地机器上一切正常&当我将浏览器指向http://localhost:3000

但是现在我计划在其中一个域名上运行这个应用,比如说http://example.org 它运行在nginx上&它是一个php代码

但是,如何使我的express应用程序在example.org/nodeapp上正确运行该应用程序? 目前,它正在考虑将example.org作为我的应用程序的基本url&因此在我的路由中搜索nodeapp时抛出404。它应该理想地将Expul.Org/NoDeApp作为BaseURL。

在我的服务器块配置中,我有以下代码

listen 80;

server_name your-domain.com;

location /nodeapp {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

您可以让nginx通过添加类似于rewrite^/nodeapp/*/$1 break的内容来重写url