Mkdocs: Problem with mkdocs serve in remote host

Created on 9 Jun 2017  路  4Comments  路  Source: mkdocs/mkdocs

Hi,
I need configure a mkdocs in a instance locate in Amazon Web Services. This instance will be access through one nginx.
All the configuration of the instance is good (Security groups, VPC, subnets, ports, etc).
When I launch the command "mkdocs serve" in my local with material theme previous install, the execution is perfect. I can watch the documents perfectly, however when
I launch the comand "mkdocs serve -a IP_INSTANCE:8000" for some reason, I can watch the documents correctly... the theme is missing or don't show.

These things are perfectly configured:

  • VPC, subnet, security groups from AWS instance. The instance has a private IP.
  • ubuntu 16.04
  • mkdocs version 0.16.3
  • python version 2.7.12
  • python packages installed

I need to access to this service through a URL like https://my_url.com/documentation
So this is the problem... If I put the context "/documentation" when I launch mkdocs serve I can't watch anything, however, if I put
all the documents inside a directory called "documentation" I can watch the documents, but not the theme... It paint very bad...
Neither I can't find documents...

In summary, I need something like this http://www.mkdocs.org/

Please, someone can help me?

Thanks.

Most helpful comment

I've run into a (possibly) related problem when running mkdocs serve inside a Docker container. I wasn't getting any response data on the published host port (using curl http://localhost inside the container worked).

My fix was to tell mkdocs to listen on all IP addresses, e.g. mkdocs serve -a 0.0.0.0:8000. This may solve your problem when running behind nginx in AWS.

All 4 comments

Please be aware that the serve command is only intended for local development and was never intended to serve a live site. I doubt it can handle concurrent connections, which is likely the cause of your problem. The serve command is only intended to be used while authoring your docs on a local machine to verify your edits, etc. Under no circumstances should you ever try to proxy a connection to the dev server.

MkDocs is a static site generator. Its intended use case is to generate static files which are deployed by being uploaded to a static file server. You could use AWS' static file server (see their docs), or if you already have an nginx instance running, you could point it at a directory of static files (see those docs). In either case, run mkdocs build and then copy the contents of the site directory to the appropriate location on your server. That is the only type of deployment we support. Any other type of deployment is out of scope for MkDcos, and not something we can help with.

We do document how to deploy to a few specific services, but even those are all static file serves which are essentially doing what I describe above. As you can see. the Other Providers section details what I summarized above in a more general case.

I've run into a (possibly) related problem when running mkdocs serve inside a Docker container. I wasn't getting any response data on the published host port (using curl http://localhost inside the container worked).

My fix was to tell mkdocs to listen on all IP addresses, e.g. mkdocs serve -a 0.0.0.0:8000. This may solve your problem when running behind nginx in AWS.

Thank you. I wanted to support local development by running this in a container, so this helped. Replies that you are using it wrong were not as helpful.

@nonplus a few hours and 2 docker for desktop installs later and I find your post.

I salute you, good sir.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

twardoch picture twardoch  路  3Comments

nodesocket picture nodesocket  路  6Comments

banj picture banj  路  6Comments

squidfunk picture squidfunk  路  3Comments

juanpmarin picture juanpmarin  路  3Comments