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

Request timeouts when installing packages due to invalid hostname #86

Open
benduran opened this issue Apr 24, 2017 · 3 comments
Open

Request timeouts when installing packages due to invalid hostname #86

benduran opened this issue Apr 24, 2017 · 3 comments

Comments

@benduran
Copy link

I'm currently hosting several versions of this library on some AWS instances. I've been having people reporting issues with package installation timeouts, which seem to be stemming from the following line of code:

image

All packages are having their baseUrl set to whatever the server's config.host property was set. In theory, this should work with no issues. In practice, however, it is relatively common to have the server's bound hostname different from the hostname client's are using for requests (think of load-balanced servers, for example).

What I think would correct this issue would be swapping over to using the requested hostname in the http request, rather than the config.host value.

Here's a screencap of the issue clients are running into when trying to use our private npm repo:
image

@hayes
Copy link
Owner

hayes commented Apr 25, 2017

Interesting, multiple host names was not something I had considered. Unfortunately, getting the actual host an http request was made against is non-trivial. Http 1.1 added the host header, which could be used, but I'm not sure how various proxies and load balancers handle that header.

Are your deployed instances being accessed from multiple host names? If not, setting config.host to use the host used by clients should work.

I think providing a config option to use req.headers.host would be reasonable, and ideally falling back to the current method if the request does not have a host header. I'll have to look a bit more into this to know if there is another solution, or if there are additional things that can be done to make more complicated setups work.

@hayes
Copy link
Owner

hayes commented Apr 25, 2017

Thanks for reporting this, I'll try to add something to help this use case in the next couple days

@hayes
Copy link
Owner

hayes commented Apr 25, 2017

I created a pr #88 to add a config option to do auto detecting of hosts. I don't think it will work perfectly in all scenarios, but if you would not mind testing it, and seeing if it works for you I can finish up the PR and get it merged. Didn't want to spend too much more time on it if it does not work for your use case.

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

Successfully merging a pull request may close this issue.

2 participants