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

host sub domain #217

Closed
Agamennon opened this issue Mar 28, 2012 · 12 comments
Closed

host sub domain #217

Agamennon opened this issue Mar 28, 2012 · 12 comments

Comments

@Agamennon
Copy link

This simple proxy server

    var httpProxy = require('http-proxy');
     httpProxy.createServer(function (req, res, proxy) {
     var options = {
           host: "localhost",
           port: 5984
         };
      proxy.proxyRequest(req, res, options);
     }).listen(5000);

if i change host:"localhost" to host:"subdomain.domainoninternet.com"
if get 'Host not found' back, is this the "www . host" issue? #150

on a related question, is there a way to set request headers before they are sent to destination? (to set Auth headers from the server)

thank you

@coderarity
Copy link
Contributor

About the request headers: you have access to the req object passed into the httpProxy.createServer function.

@coderarity
Copy link
Contributor

It works for me on master - what domain are you trying to use? Note that it will use the 'Host' header from the original request. (Hopefully this will change soon, so you can just specify "changeOrigin: true" to fix things.)

@Agamennon
Copy link
Author

@coderarity
Copy link
Contributor

I see! Let me look into it.

@coderarity
Copy link
Contributor

It seems like it's not related to #150.

@coderarity
Copy link
Contributor

Oh - you're not using the "http" in your options.host, are you? It should look like this.

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

     httpProxy.createServer(function (req, res, proxy) {

     var options = {

           host: "mydomain.cloudant.com",

           port: 5984

         };

      proxy.proxyRequest(req, res, options);

     }).listen(5000);

(which works for me)

@Agamennon
Copy link
Author

i am using host: "mydomain.cloudant.com/mydb" and it is not working
if i use that url on the browser i get the expected couchdb response, but node proxy just freezes this request and never comes back

if a try a different couchdb host like iriscouch (host: "mydomain.iriscouch.com"), i get back a "Host not found" if i qualify it like host:"mydomain.iriscouch.com/mydb" i get the same as the first problem

@coderarity
Copy link
Contributor

When I go to mydomain.cloudant.com/mydb in my web browser it gives me a 503 error. The "Host not found" error, however, is probably related to #150. I fixed that issue in my pull request here, #231, if you want to try to use my branch and see if it fixes the problem.

@indexzero
Copy link
Contributor

Looks like this should be fixed from the PR from @coderarity

@pulkitsinghal
Copy link

@indexzero I'm not quite sure how this was fixed, I still can't get a similar proxy usecase to run:

proxy.proxyRequest(req, res, {
  host: 'domain.iriscouch.com',
  port: 80
});

@jbeard4
Copy link

jbeard4 commented Aug 3, 2013

FYI, here is how I was able to get this working:

var proxy = new httpProxy.RoutingProxy({changeOrigin : true});

var routingOptions = {
    host : 'mydomain.cloudant.com',
    port : 80
};

Non-obvious, but it works.

@sparkyfen
Copy link

Anyone point me to how to fix up mine?

I am running multiple domains off one machine using this proxy, one domain with SSL, the others without.
My current implementation is: https://gist.github.com/brutalhonesty/fe66bf64f95f9d3ccb2d

Can you tell me what I need to do to get the 'status' subdomain working?

Thanks!

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

6 participants