Tag: 反向代理

错误:连接ETIMEDOUT,Node js如何在本地主机API之间进行通信

我有一些后端服务,正在监听端口8080.而我有另一个节点js API在本地端口上监听端口3000。 我怎样才能从节点服务器到后端API? 这是我的节点js代码: router.post('/', function(req, res, next) { console.log('got validate request'); var options = { host:'localhost', port:8080, path:'/***/getservice', method:'GET' } http.request(options, function (response) { console.log('response:', response); // Print the error if one occurred res.json(response); res.end(); }); }); 上面的代码会导致错误:连接ETIMEDOUT。

使用node.js代理二进制文件而不redirectstream量?

是否有可能用node.js代理一个二进制文件(在我的情况下audio/ mpeg),只是修改一些头,但不能通过你的代理服务器redirect文件的stream量? 因为我基本上只是想添加CORS头到远程audiofile,能够通过XHttpRequest打开它,这个代理似乎是一个很好的解决scheme: https : //github.com/gr2m/CORS-Proxy 但是,是否有可能在同一时间只添加标题和“redirect到”远程服务器上的二进制文件,以便实际的文件不通过代理传输?

节点反向代理基本路由问题

我有像这样设置节点反向代理 : var options = { pathnameOnly: true, router: { '/myapp': '127.0.0.1:9000', } } httpProxy.createServer(options).listen(8000); 9000根目录下的webapp有一个index.html文件, 样式表链接如下: <link rel="stylesheet" href="styles/blue.css"> 当我直接打本地主机:9000的HTML加载和CSS被发现。 然后我通过在localhost:8000 / myapp的反向代理,但是我得到一个错误404,因为localhost:9000 / styles / blue.css没有find ,因为该文件显然是在localhost:9000 / myapp / styles / blue.css 。 我的应用程序的HTML当然不知道有关反向代理,所以我不能解决这个在index.html。 所以我想我缺less一些基本的代理设置?

如何使用http-proxy隐藏node.js服务器

我正在使用以下代码在node.js上实现反向代理。 它工作正常,但问题是,当我试图访问服务器127.0.0.1:9008/“这是相当可访问的,我希望它只能通过代理服务器访问,请帮助.. var http = require('http'), httpProxy = require('http-proxy'); // // Create a proxy server with latency // var proxy = httpProxy.createProxyServer(); // // Create your server that make an operation that take a while // and then proxy de request // http.createServer(function (req, res) { // This simulate an operation that take 500ms in […]

Node Express:使用代理时res.redirect中断

我使用Apache ProxyPass(在httpd.conf中configuration),在代理后面运行节点快速应用程序: ProxyPass /nodeapp http://localhost:9009 我的应用程序使用Passport来authentication用户,所以当我访问基本path时,我应该被redirect到login页面: – 旧的redirect: http : //example.com : 9009 – > http://example.com:9009/login – 新的redirect: http : //example.com/nodeapp – > http://example.com/nodeapp/login 不幸的是,redirect不起作用: – redirect中断: http : //example.com/nodeapp – > http://example.com/login 我试图启用快速代理configuration,但这没有什么区别: app.enable('trust proxy'); **编辑:** Ethan在下面的评论中build议,我可以硬编码我所有的path,以适应新的环境,然而这将打破当我的本地计算机上运行的path('/')。 我正在寻找一个更集中的解决scheme,如果可能的话,可以适应不同的运行环境

用express.js(nodejs)ENOTFOUND错误

每当我尝试使用我的nodejs express服务器redirect到另一个网页(例如google.com)时,它将失败返回以下错误: throw er; // Unhandled stream error in pipe. ^ Error: getaddrinfo ENOTFOUND google.com at errnoException (dns.js:44:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26) 我已经尝试了许多不同的解决scheme(例如Node.js getaddrinfo ENOTFOUND )。 甚至没有我在node.js上find的(例如https://nodejs.org/api/http.html#http_http_get_options_callback )网站将无法正常工作。 现在我正在尝试最简单的版本: var express = require('express'); var app = express(); var request = require('request'); app.get('/', function(req,res) { var newurl = 'http://google.com/'; request(newurl).pipe(res); }); app.listen(1337); 或这一个 var request […]

推荐使用Heroku的多端口应用程序

正如我从SE上的其他问题了解到的,在Heroku应用程序中使用多个端口是不可能的,因为Heroku为端口指定了一个环境variables。 有没有推荐的方法来解决这个问题? 我见过一些使用子域的代理模块: Heroku + node.js:我有一个使用多个端口的服务器。 我怎样才能让Heroku分配它们? 不过,在这篇文章中: 如何在heroku上为应用程序创build一个subsubdomain :(例如,sub.myapp.herokuapp.com) 这表明heroku中的子域名不再可能。 在我的应用程序中,我正在使用express来提供我的内容,并且有一个websocket服务器用于同步一些实时内容,而这些内容都需要一个端口。 我的问题是,是否可以在heroku中使用子域名?推荐使用多个端口的Web应用程序的方式是什么?

反向代理子域到同一台机器上的不同端口将引发404

我尝试过像红redbird这样的手: 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"); 和redwire如: 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:3003成功加载各自的网页,但是当我尝试击中http://www.example.com ,我得到的是404 host not found 。 我在控制台上得到以下日志: {"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") ,它工作。

平均堆栈安装在端口80或iis下

我有一个平均堆栈应用程序,现在在Node Js和端口3000上工作。我有一个Windows Server 2016,我需要部署.Net应用程序,所以我需要IIS。 我不能使端口80上运行两个Web服务器,但我不希望用户被迫input运行我的意思应用程序的端口。 我试图与iisnode合作,但没有成功,我还阅读了有关反向代理为了将端口80上的请求redirect到另一个端口。 这两个解决scheme都可以是有效的,但是,在将其他时间花在错误的方向上之前,我会问在这种情况下最好的做法是什么。 更新:向前一步。 我现在可以访问应用程序的加载页面,但是应用程序找不到我的bundle.js(由Webpack创build的包)。 module.exports = webpackMerge.smart(commonConfig, { entry: { 'app': './assets/app/main.aot.ts' }, output: { path: path.resolve(__dirname + '/public/js/app'), filename: 'bundle.js', publicPath: '/js/app/', chunkFilename: '[id].[hash].chunk.js' }, 我的web.config是: <configuration> <system.webServer> <handlers> <add name="iisnode" path="start.js" verb="*" modules="iisnode" /> </handlers> <rewrite> <rules> <rule name="tep"> <match url="/*" /> <action type="Rewrite" url="start.js" /> </rule> </rules> […]

NodeJS – 具有路由改变的反向代理

我正在使用NodeJS / Express作为在端口80上运行在我的VPS上的简单域路由器。我的routes.coffee看起来像这样: request = require("request") module.exports = (app) -> #404, 503, error app.get "/404", (req, res, next) -> res.send "404. Sowway. :(" app.get "/error", (req, res, next) -> res.send "STOP SENDING ERRORS! It ain't cool, yo." #Domain Redirects app.all '/*', (req, res, next) -> hostname = req.headers.host.split(":")[0] #Website1.com if hostname == 'website1.com' res.status 301 […]