Skip to content

http-proxy to apache failed. #234

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

Closed
zzswang opened this issue Apr 24, 2012 · 4 comments
Closed

http-proxy to apache failed. #234

zzswang opened this issue Apr 24, 2012 · 4 comments

Comments

@zzswang
Copy link

zzswang commented Apr 24, 2012

I have an apache server running on port 82.

//proxy for apps                                                                                                                                                                                                                                                                                            
httpProxy.createServer({                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
  router:{                                                                                                                                                                                                                                                                                                  
    'cloud9.xxxx.net': 'localhost:8121',    // to a cloud app(node.js)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
    'www.xxxxx.com': 'localhost:82',        // to apache                                                                                                                                                                                                                                                              
  }                                                                                                                                                                                                                                                                                                         
}).listen(80);   

when i request http://www.xxxx.com/a/b
it always redirect to http://www.xxxx.com:82/a/b
Because of firewall. it will failed.
why port 82 will be shown up?

@coderarity
Copy link
Contributor

huh, that's weird, it definitely shouldn't redirect in your browser. That would require sending back a 300 redirect and stuff, which is a little crazy, are you sure apache isn't sending back a 300 redirect?

@zzswang
Copy link
Author

zzswang commented Apr 28, 2012

I am not very familiar with apache.
Once I used nginx as front. it can work well with apache2.

Also I google it, and find there are same issues about this. like
http://comments.gmane.org/gmane.comp.lang.javascript.nodejs/22110

@coderarity
Copy link
Contributor

Yeah, that's what I thought. Apache is sending back a redirect, like that guy says in that thread you sent. In that thread, he did state the solution:

I've found that the port number only appears when the URL points to a
directory but lacks a trailing slash. This means that I can write some
Node.js code to check the URL and, if necessary, do a 301 redirect to
a fixed URL. I haven't had time to implement this yet, but I think it
will solve the problem.

(indexzero also provided an example in response to that, check it out here)

@zzswang
Copy link
Author

zzswang commented May 4, 2012

thank you, i use another ip address for apache2. So currently my problem is resolved.

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