Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • N node-http-proxy
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 482
    • Issues 482
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 102
    • Merge requests 102
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • http ... PARTY!
  • node-http-proxy
  • Issues
  • #603
Closed
Open
Issue created Mar 21, 2014 by Administrator@rootContributor

Use node-http-proxy 1.x to proxy requests to another http server

Created by: ketan-vijayvargiya

Hello, My use-case is this: I have a proxy server running in Nodejs (created using httpProxy.createProxyServer. call it server#1). There is another proxy-server (squid-based. call it server#2) to which server#1 should proxy requests to. So basically, clients will use my server#1 as proxy for their website calls. server#1 will in turn proxy request to server#2. server#2 will actually call the requested domain and send response back to client via server#1.

I could do this in node-http-proxy v0.x by: var httpProxy = require('http-proxy') var proxy = new httpProxy.RoutingProxy(); httpProxy.createServer( function (request, response, proxy) { // blah blah proxy.proxyRequest( request, response, { host : server#2_host, port: ... } ); });

How to achieve this in node-http-proxy 1.x is the question? I expected this to work, but it doesn't: var proxy = httpProxy.createProxyServer({target: { host: server#2_host, port: ... }}); proxy.web(req, res);

Any pointers on how I can do this?

Assignee
Assign to
Time tracking