node-http-proxy

Check app running on new port

你说的曾经没有我的故事 提交于 2019-12-11 03:26:48
问题 I need to create application which get request for specific port and proxy it to new server on different port for example the following port 3000 will be proxy to port 9000 and you actually run the application on 9000 ( under the hood) since the user in the client click on 3000 http://localhost:3000/a/b/c http://localhost:9000/a/b/c I try something like var proxy = httpProxy.createProxyServer({}); http.createServer(function (req, res) { var hostname = req.headers.host.split(":")[0]; var

How to reverse proxy client POST & PUT requests using node-http-proxy

戏子无情 提交于 2019-12-09 15:57:08
问题 I'm trying to use the node-http-proxy as a reverse proxy, but I can't seem to get POST and PUT requests to work. The file server1.js is the reverse proxy (at least for requests with the url "/forward-this") and server2.js is the server that receives the proxied requests. Please explain what I'm doing incorrectly. Here's the code for server1.js: // File: server1.js // var http = require('http'); var httpProxy = require('http-proxy'); httpProxy.createServer(function (req, res, proxy) { if (req

Default route using node-http-proxy?

≡放荡痞女 提交于 2019-12-09 06:54:42
问题 I want to do a simple node.js reverse proxy to host multiple Node.JS applications along with my apache server on the same port 80. So I found this example here var http = require('http') , httpProxy = require('http-proxy'); httpProxy.createServer({ hostnameOnly: true, router: { 'www.my-domain.com': '127.0.0.1:3001', 'www.my-other-domain.de' : '127.0.0.1:3002' } }).listen(80); The problem is that I want to have for example app1.my-domain.com pointing to localhost:3001, app2.my-domain.com

socket.io example sometimes not connecting client side when using a reverse proxy

守給你的承諾、 提交于 2019-12-08 09:35:16
问题 Using node-http-proxy, I've set up a reverse proxy for routing requests: var httpProxy = require('http-proxy'); var server = httpProxy.createServer({ hostnameOnly: true, router: { 'www.example.com': 'localhost:3002' } }).listen(80); Now, when I run the first example on http://socket.io/#how-to-use, the socket is sometimes not connecting with the client. I created two files to test this: server.js and index.html. To start the node application, i run server.js. server.js: var app = require(

creating a forward https proxy using http-node-proxy

人盡茶涼 提交于 2019-12-08 05:34:16
问题 I am trying to create a forward proxy capable of handling HTTPS websites as well. I am trying to observe and modify traffic for different sites. This is my code which works for http sites but not for https sites. httpProxy.createServer(function(req, res, next) { //custom logic next(); }, function(req, res) { var proxy = new httpProxy.RoutingProxy(); var buffer = httpProxy.buffer(req); var urlObj = url.parse(req.url); req.headers.host = urlObj.host; req.url = urlObj.path; console.log(urlObj

proxy http request with node

人盡茶涼 提交于 2019-12-08 02:19:59
问题 I have a nodeJs front end on one domain and a rest back end server on another domain. I would like to be able to perform ajax requests from the front to the back. So, i intend to use a reverse proxy for that, in order to bypass the same origin policy restriction. My back end Rest server will be secured with Basic auth or OAuth. I would like to know, if i use node-http-proxy if it is possible to send an Authorization header in the http request before proxying it, and how. Thanks a lot. 回答1:

How to run node.js app on port 80 using http-proxy?

独自空忆成欢 提交于 2019-12-06 16:00:45
问题 I want to run my node.js app on port 80 on Apache server. I have tried 2 methods one via Apache: <VirtualHost *:80> ServerName domainName.com ServerAlias www.domainName.com ProxyRequests off <Proxy *> Order deny,allow Allow from all </Proxy> <Location /> ProxyPass http://domainName:8080 ProxyPassReverse http://domainName:8080 </Location> </VirtualHost> When I use this I get 502 proxy error in Chrome console. The server cannot find my CSS and Socket.io and other JS files. UPDATE: I solved this

creating a forward https proxy using http-node-proxy

穿精又带淫゛_ 提交于 2019-12-06 15:47:47
I am trying to create a forward proxy capable of handling HTTPS websites as well. I am trying to observe and modify traffic for different sites. This is my code which works for http sites but not for https sites. httpProxy.createServer(function(req, res, next) { //custom logic next(); }, function(req, res) { var proxy = new httpProxy.RoutingProxy(); var buffer = httpProxy.buffer(req); var urlObj = url.parse(req.url); req.headers.host = urlObj.host; req.url = urlObj.path; console.log(urlObj.protocol); setTimeout(function() { proxy.proxyRequest(req, res, { host: urlObj.host, port: 80, buffer:

How to reverse proxy client POST & PUT requests using node-http-proxy

半腔热情 提交于 2019-12-04 03:37:19
I'm trying to use the node-http-proxy as a reverse proxy, but I can't seem to get POST and PUT requests to work. The file server1.js is the reverse proxy (at least for requests with the url "/forward-this") and server2.js is the server that receives the proxied requests. Please explain what I'm doing incorrectly. Here's the code for server1.js: // File: server1.js // var http = require('http'); var httpProxy = require('http-proxy'); httpProxy.createServer(function (req, res, proxy) { if (req.method == 'POST' || req.method == 'PUT') { req.body = ''; req.addListener('data', function(chunk) { req

nginx vs node-http-proxy

一曲冷凌霜 提交于 2019-12-03 18:32:27
问题 Tell me please what is preferable to use for deployment of nodejs applications nginx or node-http-proxy. What is most robust? The basic features I need are proxy all requests to non 80 post load balancer Websocket supporting 回答1: Here is a great article on the subject http://www.exratione.com/2012/07/proxying-websocket-traffic-for-nodejs-the-present-state-of-play/ Personally I have played with a lot of configurations in this realm and it all comes down to what you need and where you need to