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 header is specified and is not an IP address or localhost. #40

Open
hbakhtiyor opened this issue Apr 22, 2018 · 12 comments
Open

Host header is specified and is not an IP address or localhost. #40

hbakhtiyor opened this issue Apr 22, 2018 · 12 comments

Comments

@hbakhtiyor
Copy link

getting this error in the latest of stable chrome

@alphonse92
Copy link

I have the same issue

@yukinying
Copy link
Owner

Can you provide more details? Are you having this issue in the chrome version or the selenium version?

@pcambra
Copy link

pcambra commented May 7, 2018

This seems to be a known issue with Chrome 66, but I'm struggling to find how to workaround it, more details:

puppeteer/puppeteer#2242
OnetapInc/chromy#110

@adamgotterer
Copy link

The only suitable workaround I've found is to pin to the last known version of chrome where this problem didn't exist yukinying/chrome-headless-browser:65.0.3322.3

@hbakhtiyor
Copy link
Author

@yukinying any possible way to use proxy inside the image? proxy catches incoming requests and send to chrome instance, the proxy and chrome instance in the same docker container

@wholegroup
Copy link

@hbakhtiyor Also you can map docker host IP to /etc/hosts and connect to a chrome instance via created host name, this issue about only if you use IP

@hbakhtiyor
Copy link
Author

hi @wholegroup, the issue is that the same ip address uses for many subdomains (which has different instances)

@wholegroup
Copy link

@hbakhtiyor I can't see your configuration, but still I don't see any problems.

before

ws://172.0.0.1:9223/devtools/page/FF3312E555CDEADBC3759BF0DE46B72B

after

ws://host-172-0-0-1:9223/devtools/page/FF3312E555CDEADBC3759BF0DE46B72B

/etc/hosts on a client

172.0.0.1 host-172-0-0-1

It is almost the same.

@foxundermoon
Copy link

same issue with chromium 72 when a request by domain.

with ip ok,
http://51.145.11.246:9222

http://spider.fox.mn:9222

@foxundermoon
Copy link

bool RequestIsSafeToServe(const net::HttpServerRequestInfo& info) {
  // For browser-originating requests, serve only those that are coming from
  // pages loaded off localhost or fixed IPs.
  std::string header = info.headers["host"];
  if (header.empty())
    return true;
  GURL url = GURL("http://" + header);
  return url.HostIsIPAddress() || net::IsLocalHostname(url.host(), nullptr);
}
  if (!RequestIsSafeToServe(info)) {
    Send500(connection_id,
            "Host header is specified and is not an IP address or localhost.");
    return;
  }

why domain not safe?

@m7shapan
Copy link

m7shapan commented Nov 5, 2019

Hello,
I was stuck at this problem as well until I found a workaround for it.
so my workaround was to override the host header and set it to localhost the replace the actual host by localhost on webSocketDebuggerUrl
my implementation on Golang for this workaround:
chromedp/chromedp#505 (comment)

@ahsanshah
Copy link

I am running into this issue when attempting to load balance NGINX upstream to a set of chrome headless pods. I am invoking the CDP commands externally from a different docker container. @m7shapan can you advise on where exactly the above workaround can be implemented? alternatively, Is there any flag directly that can resolve this in the more recent releases?

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

9 participants