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

Reverse proxying Google Maps does not work with http-proxy #177

Closed
jwchang0206 opened this issue Jan 14, 2012 · 8 comments
Closed

Reverse proxying Google Maps does not work with http-proxy #177

jwchang0206 opened this issue Jan 14, 2012 · 8 comments

Comments

@jwchang0206
Copy link

ex) http://maps.google.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

With Nginx,

location /geocode {
    proxy_pass http://maps.google.com/maps/api/geocode
}

Works nicely.

But somehow with node-http-proxy,

httpProxy.createServer({
    router: {
        'localhost/geocode': 'maps.google.com/maps/api/geocode'
    }
}).listen(80);

Does not work.

I guess Nginx and node-http-proxy handles header differently :( ex) X-Forwarded-For, Referer and etc.

I want to use node-http-proxy :) instead of nginx to make this work.

Would you take some time to change header values when reverse proxying?

@jwchang0206
Copy link
Author

Below is my example code snippet (jQuery code) that works well with Nginx's "proxy_pass"

$.getJSON( '/geocode/json?latlng=40.714224,-73.961452&sensor=true&language=en', function(data) {
    // successfully loaded data when data.status equals to "OK"
});

@indexzero
Copy link
Contributor

Need some more info here:

  1. What exact header values do you want changed? You mentioned x-forwarded-for and referer, others? The list needs to be exhaustive
  2. What are the values of these headers now?
  3. What should they be? And why?

@jwchang0206
Copy link
Author

That was what I was asking you.. What those values of headers should be..

How nginx proxy headers are different from http-proxy headers..

and implementation.....

@indexzero
Copy link
Contributor

I don't really know nginx ... we do set them.

@jwchang0206
Copy link
Author

What about making exact same behavior as access from a browser? That would work since

ex) http://maps.google.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true

url works through browsers :)

@jwchang0206
Copy link
Author

@indexzero
Do node-http-proxy actually set headers as a client or as a server? I think nginx is sending headers as a client.

@coderarity
Copy link
Contributor

It's because you're using a subdomain, see #217 (which doesn't have much yet, but I'm going to work on this soon). Or at least - I think it is =D

@indexzero
Copy link
Contributor

Fixed along with #217

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

No branches or pull requests

3 participants