Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to configure tunneling proxy #68

Closed
samithaf opened this issue Apr 14, 2016 · 5 comments
Closed

How to configure tunneling proxy #68

samithaf opened this issue Apr 14, 2016 · 5 comments
Labels

Comments

@samithaf
Copy link

Problem Description

I am using proxy middleware to communicate with an endpoint which lives in open internet but I am behind a corporate proxy. So when I try to connect to the endpoint I am getting following error.

ROXY ERROR: ENOTFOUND. localhost:3000 -> https://www.example.com.au/login

I wonder how to configure agent for http-proxy-middleware.

I have tested a simple https with a agent and works fine and code as follows.

var tunnel = require('tunnel');
var tunnelingAgent = tunnel.httpsOverHttp({
  proxy: {
    host: 'office.proxy.com.au',
    port: 8080
  }
})

var https = require('https')
  var post_req = https.request({
    host: 'www.example.com.au',
    port: '443',
    path: '/logon',
    method: 'GET',
    agent: tunnelingAgent,
    timeout: 10000,
    followRedirect: true,
    maxRedirects: 10
  }, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
      console.log('Response: ' + chunk);
    });
  });
  post_req.write("name=mario");
  post_req.end();
@chimurai
Copy link
Owner

This question is probably related to: #22

You might want to check out the corporate proxy example: https://github.com/chimurai/http-proxy-middleware/blob/master/recipes/corporate-proxy.md

Try to use https-proxy-agent instead of tunnel. Hopefully it will give the desired result.

@samithaf
Copy link
Author

@chimurai thanks heaps for the reply. I will check first thing in the morning (Aus/Syd) time and update the thread

@samithaf
Copy link
Author

I am closing this since it's works perfectly well when I pass a https agent as @chimurai mentioned in the post

@Tits-McGee
Copy link

Tits-McGee commented Dec 11, 2018

@chimurai
Sorry to bring up such an old issue!
When using this solution, proxyReq.SetHeader breaks - the error message is Cannot set headers after they are sent to the client
Any help will be appreciated!

@jaredxx1
Copy link

#22

Same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants