我在 PORT 上運行的上游服務器 -3000
var express = require('express')
var app = express()
app.get('/', function (req, res) {
res.send('Hello World!')
})
app.get('/test',function(req,res){
res.send('<h1>Testing...</h1>')
})
app.listen(3000, function () {
console.log('Listening on port 3000...')
})
我可以在瀏覽器中輕松查看兩條路線


從 ngnix -> Node 設定代理
我嘗試了以下配置
location ^~ /* {
try_files $uri $uri/ =404;
proxy_pass http://localhost:3000/$1;
}
========================================
location / {
try_files $uri $uri/ =404;
proxy_pass http://localhost:3000/;
}
========================================
location /* {
try_files $uri $uri/ =404;
proxy_pass http://localhost:3000/$1;
}
以上所有配置正在加載http://localhost/但 404 onhttp://localhost/test
uj5u.com熱心網友回復:
try_files提供靜態檔案。洗掉此行。
location / {
proxy_pass http://localhost:3000/;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/445741.html
上一篇:如何獲取類中變數的所有值?
