Node.js 将子域反向代理到同一台计算机上的不同端口抛出404
我试了试红鸟,比如:Node.js 将子域反向代理到同一台计算机上的不同端口抛出404,node.js,reverse-proxy,diet-js,redbird,redwire,Node.js,Reverse Proxy,Diet Js,Redbird,Redwire,我试了试红鸟,比如: var proxy = require('redbird')({port: 80}); proxy.register("http://www.example.com", "http://36.154.99.115:3000"); proxy.register("http://abc.example.com", "http://36.154.99.115:3001"); proxy.register("http://xyz.example.com", "http://36.
var proxy = require('redbird')({port: 80});
proxy.register("http://www.example.com", "http://36.154.99.115:3000");
proxy.register("http://abc.example.com", "http://36.154.99.115:3001");
proxy.register("http://xyz.example.com", "http://36.154.99.115:3002");
var RedWire = require('redwire');
proxy = new RedWire({http: { port: 80 }});
proxy.http("http://www.example.com", "http://36.154.99.115:3000");
proxy.http("http://abc.example.com", "http://36.154.99.115:3001");
proxy.http("http://xyz.example.com", "http://36.154.99.115:3002");
和redwire
类似:
var proxy = require('redbird')({port: 80});
proxy.register("http://www.example.com", "http://36.154.99.115:3000");
proxy.register("http://abc.example.com", "http://36.154.99.115:3001");
proxy.register("http://xyz.example.com", "http://36.154.99.115:3002");
var RedWire = require('redwire');
proxy = new RedWire({http: { port: 80 }});
proxy.http("http://www.example.com", "http://36.154.99.115:3000");
proxy.http("http://abc.example.com", "http://36.154.99.115:3001");
proxy.http("http://xyz.example.com", "http://36.154.99.115:3002");
我可以点击http://36.154.99.115:3000
,http://36.154.99.115:3001
和http://36.154.99.115:3003
成功加载相应的网页,但当我尝试点击http://www.example.com
,我得到的只是404主机未找到
我在控制台上获得以下日志:
{"name":"redbird","hostname":"ip-172-31-23-160","pid":3239,"level":30,"msg":"Proxying www.example.com/ to www.example.com:3000/","time":"2017-02-12T08:07:57.540Z","v":0}
这看起来很成功,但实际上不起作用
在3000、3001和3002上运行的服务器正在使用DietJS
,如果这很重要的话
注意:我尝试了proxy.register(“http://www.example.com", "http://www.facebook.com”
,它成功了
这里的问题似乎是Diet.js,请尝试将web服务器移植到Express.js
或者,尝试使用Express.js或其他相对通用的工具创建一个示例应用程序,并尝试重定向到它。如果这能奏效(希望如此),你知道该怎么做