0
我目前有一個連接到域的數字海洋液滴。在服務器上,我正在運行NGINX,並嘗試將代理多節點應用程序反轉到它。目前,我的根目錄有一個節點快速應用程序,位於/。在子目錄中使用NGINX的多節點應用程序
我試圖將另一個節點快速應用程序連接到另一個子目錄。下面是nginx的配置文件:
server {
listen 80;
server_name servername.com;
# my root app
location/{
proxy_pass http://127.0.0.1:6001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# new app
location ~^ /newapp {
proxy_pass http://127.0.0.1:6002;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
的問題是,新的應用程序試圖之外提供文件,/ NEWAPP,這是破的。我認爲這可能是我的app.js文件中的一些東西,用於在新應用中使用Express,將基本目錄設置爲/ newapp/- 以便從那裏提供靜態文件和路由。任何想法如何做到這一點?
在NEWAPP,我提供靜態文件,例如:
// Serve files out of ./public
app.use(express.static(__dirname + '/public'));
,並有路線文件作爲:
var index = require('./routes/index');
app.use('/', index);
索引路由文件:
var express = require('express');
var router = express.Router();
// Get index page
router.get('/', function(req, res, next) {
res.render('index', {
index : 'active'
});
});
module.exports = router;