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

Disallow 0.0.0.0 dev_addr. #2022

Merged
merged 4 commits into from Mar 12, 2020
Merged

Disallow 0.0.0.0 dev_addr. #2022

merged 4 commits into from Mar 12, 2020

Conversation

waylan
Copy link
Member

@waylan waylan commented Mar 11, 2020

MkDocs has never supported using the included server for production.
However, some users have been using it that way. This would prevent that.

Still needs proper tests. However, a quick test on the command line produces these results:

λ mkdocs serve -a 0.0.0.0:8000
INFO    -  Building documentation...
ERROR   -  Config value: 'dev_addr'. Error: The MkDocs' server is intended for 
development purposes only. Therefore, '0.0.0.0' is not a supported IP address.
Please use a third party production-ready server instead.

Aborted with 1 Configuration Errors!
λ mkdocs serve -a 277.0.0.0:8000
INFO    -  Building documentation...
ERROR   -  Config value: 'dev_addr'. Error: '277.0.0.0' does not appear to be an
IPv4 or IPv6 address

Aborted with 1 Configuration Errors!

waylan added 2 commits Mar 11, 2020
MkDocs has never supported using the included server for production.
However, some users have been using it that way. This would prevent that.
@waylan
Copy link
Member Author

waylan commented Mar 11, 2020

How nice. We apparently have been using invalid IP addresses in our tests. Well, now we can clean that up too.

@waylan
Copy link
Member Author

waylan commented Mar 11, 2020

So ipaddress.ip_address does not accept the square brackets when validating an IPv6 address. However, the user should supply them as they are required in a URL and dev_addr includes the port so that is a URL. Need to add some additional logic for that. In other words, the failing tests are correct. The validation needs to be adjusted so that the tests pass.

@waylan
Copy link
Member Author

waylan commented Mar 12, 2020

This is getting weirder.

$ mkdocs serve -a [::1]:8000
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 1.22 seconds
INFO    -  Serving on http://[::1]:8000

[Errno 8] nodename nor servname provided, or not known
$ mkdocs serve -a ::1:8000
INFO    -  Building documentation...
INFO    -  Cleaning site directory
INFO    -  Documentation built in 1.18 seconds
INFO    -  Serving on http://::1:8000
INFO    -  Start watching changes
INFO    -  Start detecting changes

[::1]:8000 causes the server to error out, but ::1:8000 works fine. However, with the server running at ::1:8000, from the browser, http://[::1]:8000 works, but http://::1:8000 fails.

@waylan waylan force-pushed the dev-addr branch 3 times, most recently from c36c7ec to ac5412b Compare Mar 12, 2020
@waylan waylan merged commit 653ba22 into mkdocs:master Mar 12, 2020
2 checks passed
@waylan waylan deleted the dev-addr branch Mar 12, 2020
@hason
Copy link

hason commented May 13, 2020

@waylan This change complicates local development with docker containers. Why do you care what IP address user can get there? It's user responsibility and decision.

@dschmidt
Copy link

dschmidt commented May 13, 2020

@waylan This change complicates local development with docker containers. Why do you care what IP address user can get there? It's user responsibility and decision.

Complicates? Do you have a workaround already?

@waylan
Copy link
Member Author

waylan commented May 13, 2020

Why do you care what IP address user can get there?

As has been explained many times, we do not support using our server for anything except on the local device. Using 0.0.0.0 allows people to use the server outside of what we support and leads to a constant stream of support requests to for help in addressing problems with their setup. By disallowing 0.0.0.0 and displaying a message explaining it is not supported, the idea was that this would lessen the misguided requests from users.

@cirego
Copy link

cirego commented May 14, 2020

@waylan This change complicates local development with docker containers. Why do you care what IP address user can get there? It's user responsibility and decision.

I am also a user negatively impacted by this decision because I run mkdocs serve inside of Docker containers for my local development workflow. This simplifies our workflow by reducing the number of dependencies on the developer system. I then have a wrapper script around docker run that uses --mount to expose my source files into the container, which the server will then see changes live. I get the best of both worlds: edit the files on my local machine while using Docker for managing dependencies.

The only workaround that I have right now is to use host mode (--network host) when running the server. The problem with this solution is that:

  1. The container now has the ability to query services running on my local host and I have lost network isolation for the code running in the container.
  2. I cannot remap ports from inside the container to be different ports outside my container. This prevents, for example, the ability to run multiple development servers on the same host.

For production, I have a workflow that builds the static site and hosts via Nginx.

@cirego
Copy link

cirego commented May 14, 2020

Of course, the other obvious workaround is pip install mkdocs==1.1.

@waylan
Copy link
Member Author

waylan commented May 14, 2020

The conversation regarding this change is in #2108. Please follow up there.

@mkdocs mkdocs locked as resolved and limited conversation to collaborators May 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants