[英]Is it possible to specify a directory on the server when proxying with node-http-proxy?
我使用http代理代理任何PHP請求通過apache但我無法弄清楚如何代理服務器上的目錄...例如,如果它的PHP文件我說:localhost:8090 / bar.php - > localhost:80 / bar.php但我想代理到localhost:80 / foo / bar.php我想遠離任何URL重寫但是。 謝謝
我已經在下面測試了我的解決方案,它似乎工作正常,但我不能100%確定它是否是實現此目的的最佳方法:
var http = require('http'),
httpProxy = require('http-proxy'),
proxy = new httpProxy.RoutingProxy();
http.createServer(function (req, res) {
req.url = '/foo' + req.url;
proxy.proxyRequest(req, res, {
host: 'localhost',
port: '80'
});
}).listen(8090);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.