[英]How to setup subpath proxy in nginx
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...')
})
我可以很容易地在浏览器中看到两条路线
我尝试了以下配置
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/
但在http://localhost/test
上加载 404
try_files
提供 static 个文件。 删除此行。
location / {
proxy_pass http://localhost:3000/;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.