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

Invalid domain character when specifying port #2166

Open
codedge opened this issue Mar 12, 2024 · 4 comments
Open

Invalid domain character when specifying port #2166

codedge opened this issue Mar 12, 2024 · 4 comments

Comments

@codedge
Copy link

codedge commented Mar 12, 2024

System

  • Version: 0.34
  • Platform: Linux
  • Firefox: 123.0.1
  • Selenium:

I run geckodriver in a separate Docker container and want to allow a certain header+port via the --allow-hosts parameter.

services:
  php:
    build: .
    ports:
      - "9029:80"

  webdriver:
    image: instrumentisto/geckodriver:latest
    command:
      - --binary=/opt/firefox/firefox
      - --host=0.0.0.0
      - --port=4444
      - --allow-hosts=localhost,webdriver:4444
      - --log=debug
    ports:
      - "4444:4444"

Either via docker-compose or directly on the command line, I get the error

geckodriver: error: invalid value 'localhost,webdriver,webdriver:4444' for '--allow-hosts <ALLOW_HOSTS>...': invalid domain character

I need the port specified inside the --allow-hosts , otherwise I get Invalid Host header webdriver:4444 when calling the webdriver container.

Any advice?

@jgraham
Copy link
Member

jgraham commented Mar 13, 2024

It looks like we currently don't support passing in a port to --allow-hosts, but expect the port in the request's Host header to match the port the server is bound to: https://searchfox.org/mozilla-central/source/testing/webdriver/src/server.rs#339

It seems like that could be broken in some port-forwarding setups, but I'm a bit surprised if it doesn't work when you're matching the ports inside and outside the container.

@whimboo
Copy link
Collaborator

whimboo commented Mar 19, 2024

@codedge could you please check if the workaround @jgraham mentioned works for you temporary?

@codedge
Copy link
Author

codedge commented Mar 19, 2024

The only thing that does work is

services:
  php:
    build: .
    ports:
      - "9029:80"

  webdriver:
    image: instrumentisto/geckodriver:latest
    command:
      - --binary=/opt/firefox/firefox
      - --host=0.0.0.0
      - --port=80
      - --allow-hosts=localhost,webdriver
      - --log=debug
    ports:
      - "80:80"

This way I can whitelist http://webdriver without port, as 80 is the default for HTTP. If I mix something up here, can you please post a docker-compose config, like mine, with the values you think work better?

@whimboo
Copy link
Collaborator

whimboo commented Apr 9, 2024

It looks like we currently don't support passing in a port to --allow-hosts, but expect the port in the request's Host header to match the port the server is bound to: https://searchfox.org/mozilla-central/source/testing/webdriver/src/server.rs#339

@jgraham, given that the argument is about the host and not the port, shouldn't we actually ignore the port? With --allow-origin we have another argument that is used to prevent connections from unwanted locations and this includes checks for the port. Or do I miss something?

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