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

Heroku - proxy server not working with browser #858

Open
TelmoNeves opened this Issue Jul 24, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@TelmoNeves

TelmoNeves commented Jul 24, 2015

I have the following code in my heroku app:

var http = require('http'),
httpProxy = require('http-proxy');

var proxy = httpProxy.createProxyServer({});

http.createServer(function(req, res) {
  proxy.web(req, res, {target:req.url, prependPath:false})
}).listen(process.env.PORT || 5000);

console.log("Server started on port "+process.env.PORT);

And then I'm trying to use this server along with a browser (e.g. Chrome) using appname.herokuapp.com:80 or using the port returned by console log function but only using the port 80 works yet it only says that the app doesn't exists when it does.

@keithmo

This comment has been minimized.

Show comment
Hide comment
@keithmo

keithmo Jul 24, 2015

When running in the Heroku environment, your app is already behind a proxy. The Heroku proxy is bound to appname.herokuapp.com:80, and forwards requests to your app dyno, which is bound to some randomly assigned port.

What exactly are you trying to do? Setting target to req.url seems quite odd.

keithmo commented Jul 24, 2015

When running in the Heroku environment, your app is already behind a proxy. The Heroku proxy is bound to appname.herokuapp.com:80, and forwards requests to your app dyno, which is bound to some randomly assigned port.

What exactly are you trying to do? Setting target to req.url seems quite odd.

@TelmoNeves

This comment has been minimized.

Show comment
Hide comment
@TelmoNeves

TelmoNeves Jul 24, 2015

What I'm trying to do is to setup a caching proxy server like squid in heroku. Then I want to be able to use that proxy server on any browser like 111.222.333.444:80.

I don't know exactly what I'm doing since I never used nodejs but from what I can see, that piece of code makes a request from the url I'm trying to access, say google.com, and then returns the response to heroku and so to my browser right?

I'm aware that heroku already use a proxy yet I don't know how it works.

TelmoNeves commented Jul 24, 2015

What I'm trying to do is to setup a caching proxy server like squid in heroku. Then I want to be able to use that proxy server on any browser like 111.222.333.444:80.

I don't know exactly what I'm doing since I never used nodejs but from what I can see, that piece of code makes a request from the url I'm trying to access, say google.com, and then returns the response to heroku and so to my browser right?

I'm aware that heroku already use a proxy yet I don't know how it works.

@TelmoNeves

This comment has been minimized.

Show comment
Hide comment
@TelmoNeves

TelmoNeves Jul 25, 2015

Other people already questioned about this: #301

TelmoNeves commented Jul 25, 2015

Other people already questioned about this: #301

@ShayBox

This comment has been minimized.

Show comment
Hide comment
@ShayBox

ShayBox Apr 3, 2018

I want to do this too, but that other issue is closed and not solved, at all.

ShayBox commented Apr 3, 2018

I want to do this too, but that other issue is closed and not solved, at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment