-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Only constructor options are passed to the passes
functions
#510
Comments
…arse the per proxy args into options. fixes #510
This issue is still present ( I am using node v0.10.25 and http-proxy v1.0.2 ). Why it has been closed ? |
@pmalek can you show me a |
@jcrugzz something like this https://gist.github.com/pmalek/8756997 although I have tried many more options to pass in there but all the time I get the same issue
|
@pmalek look at the |
@jcrugzz I have changed my options to look like this : var options = {
target: "https://localhost",
ssl: {
key: fs.readFileSync('./ssl/key.pem'),
cert: fs.readFileSync('./ssl/cert.pem')
},
ws: true,
secure: true,
xfwd: true
}; and my var proxy = httpProxy.createServer(options); ( I have tried to remove the |
@pmalek Got it so there is a slight caveat here because of how the Since I have not figured out a clean way to make this more clear without making |
@jcrugzz Can you provide a BTW: I already have an https server, that's what I need this proxy to redirect all of the clients to go from |
@pmalek ok lets back up a second, I misunderstood the use case. I thought you were proxying the other way around for whatever reason. What is the exact purpose of your proxy in this case? Until then I'll take a stab at what you MIGHT want. var http = require('http');
var HttpProxy = require('http-proxy');
var Agent = http.Agent;
var options = {
target: "https://localhost",
ssl: {
key: fs.readFileSync('./ssl/key.pem'),
cert: fs.readFileSync('./ssl/cert.pem')
},
secure: true,
xfwd: true
};
//
// Note this is the same as HttpProxy.createServer(options) etc..
// It only becomes a "server" if you call listen, otherwise its just a proxy EventEmitter.
//
var proxy = new HttpProxy(options);
//
// So since we are using the certificate for making CLIENT requests, we need to make an `http`
// server, otherwise we assume `https` and use the certs for the proxy server as well.
//
var server = http.createServer(function (req, res) {
proxy.web(req, res);
});
server.on('upgrade', function(req, socket, head) {
proxy.ws(req, socket, head);
};
server.listen(80); |
@jcrugzz My exact intentions are as follows: I have a working sails web server on port So I thought using a I have tried your solution and I have the following error :
After that I have tried to change Yet still I would like to redirect clients to I have found this connected case request/request#418 and SO question https://stackoverflow.com/questions/14088787/hostname-ip-doesnt-match-certificates-altname which suggest to use
or
while passing arguments to tls server but those didn't work for me (still the error). |
@pmalek the problem is what I outlined in #563 regarding self signed certs. Since you were supplying the ssl credentials I thought this wouldn't be an issue but I was wrong ;). You need an agent in order for var http = require('http');
var HttpProxy = require('http-proxy');
var Agent = http.Agent;
var options = {
target: "https://localhost",
ssl: {
key: fs.readFileSync('./ssl/key.pem'),
cert: fs.readFileSync('./ssl/cert.pem')
},
secure: false,
xfwd: true,
agent: new Agent({ maxSockets: Infinity })
};
//
// Note this is the same as HttpProxy.createServer(options) etc..
// It only becomes a "server" if you call listen, otherwise its just a proxy EventEmitter.
//
var proxy = new HttpProxy(options);
//
// So since we are using the certificate for making CLIENT requests, we need to make an `http`
// server, otherwise we assume `https` and use the certs for the proxy server as well.
//
var server = http.createServer(function (req, res) {
proxy.web(req, res);
});
server.on('upgrade', function(req, socket, head) {
proxy.ws(req, socket, head);
});
server.listen(80); |
@jcrugzz I get this "loop" (no response/timeout) again on port So let's summarize:
|
@pmalek hmm ok, my mistake here is that this agent should be an |
@jcrugzz This still gave me the same result (or Maybe some other time. |
@pmalek Ensure you still have |
I'm still getting the same error from the simplest of examples.
is coming from
|
@blairn you are using an old api. And please create a new issue if you are having a problem using the new api :). |
Thanks! |
All of this options parsing that is found here is not being utilized. We are extending the global
this.options
but not passing them into any of thepasses
. I will see if the fix is as trivial as it seems otherwise I'll let you handle it @yawnt.The text was updated successfully, but these errors were encountered: