AVATEAM-IT-SYSTEMHAUS / mkdocs-kroki-plugin

MkDocs plugin for Kroki-Diagrams
MIT License
46 stars 28 forks source link

DownloadImages fails (docker version of mkdocs) #11

Closed Epithumia closed 9 months ago

Epithumia commented 2 years ago

Using the current latest version of mkdocs and this plugin in a docker container, the plugin fails to retrieve/save images, both from kroki.io and from a self hosted, local kroki server.

If DownloadImages is set to False, everything works fine (both online and local).

Log says it's an HTTP 403 error: forbidden.

This looks similar to https://github.com/AVATEAM-IT-SYSTEMHAUS/mkdocs-kroki-plugin/issues/10, but fails locally too.

b-bittner commented 2 years ago

I @Epithumia , thanks for your post, I will try to help you and narrow down the problem.

Can you tell me which part of the log says 403 forbidden? Could it be that the request from the client (with a possible wrong URL/Hostname) is causing this log entry? (and not the part where the plugin downloads the rendered image and saves it locally)

Could you provide more details, e.g. the log you mentioned?

Epithumia commented 2 years ago

This is the console log with a local kroki container serving on port 9000:

> docker run --rm -it -p 8880:8000 --user "$(id -u):$(id -g)" -v ${PWD}:/docs mkdocs-grendel
[...]
INFO     -  [06:33:51] Detected file changes
INFO     -  Building documentation...
WARNING  -  Config value: 'dev_addr'. Warning: The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect to the MkDocs server. However, the MkDocs'
            server is intended for local development purposes only. Please use a third party production-ready server instead.
INFO     -  kroki.plugin on_config: {'ServerURL': 'http://0.0.0.0:9000', 'EnableBlockDiag': True, 'Enablebpmn': True, 'EnableExcalidraw': True, 'EnableMermaid': True, 'DownloadImages': True,
            'EmbedImages': True, 'DownloadDir': 'images/kroki_generated', 'FencePrefix': 'kroki-'}
ERROR    -  kroki.plugin <urlopen error [Errno 111] Connection refused>: http://0.0.0.0:9000/graphviz/svg/eNrFUcFqhDAUvPsVI..
ERROR    -  kroki.plugin <urlopen error [Errno 111] Connection refused>: http://0.0.0.0:9000/pikchr/svg/eNqdVltP4kAUfu-vmLC..
ERROR    -  kroki.plugin <urlopen error [Errno 111] Connection refused>: http://0.0.0.0:9000/blockdiag/svg/eNpdzEEKgzAQheG9..
INFO     -  kroki.plugin Cleaning <TemporaryDirectory '/tmp/mkdocs_kroki_se0ossr0'>
INFO     -  [06:33:51] Reloading browsers
INFO     -  [06:33:52] Browser connected: http://0.0.0.0:8880/?vscodeBrowserReqId=1653062505033
INFO     -  [06:33:53] Browser connected: http://0.0.0.0:8880/

If I change the URL to the kroki.io service:

INFO     -  [06:37:05] Detected file changes
INFO     -  Building documentation...
WARNING  -  Config value: 'dev_addr'. Warning: The use of the IP address '0.0.0.0' suggests a production environment or the use of a proxy to connect to the MkDocs server. However, the MkDocs'
            server is intended for local development purposes only. Please use a third party production-ready server instead.
INFO     -  kroki.plugin on_config: {'ServerURL': 'https://kroki.io', 'EnableBlockDiag': True, 'Enablebpmn': True, 'EnableExcalidraw': True, 'EnableMermaid': True, 'DownloadImages': True,
            'EmbedImages': True, 'DownloadDir': 'images/kroki_generated', 'FencePrefix': 'kroki-'}
ERROR    -  kroki.plugin HTTP Error 403: Forbidden: https://kroki.io/graphviz/svg/eNrFUcFqhDAUvPsVIfdi..
ERROR    -  kroki.plugin HTTP Error 403: Forbidden: https://kroki.io/pikchr/svg/eNqdVltP4kAUfu-vmLC7ib..
ERROR    -  kroki.plugin HTTP Error 403: Forbidden: https://kroki.io/blockdiag/svg/eNpdzEEKgzAQheG9p5h..
INFO     -  kroki.plugin Cleaning <TemporaryDirectory '/tmp/mkdocs_kroki_h10vqzqp'>
INFO     -  [06:37:06] Reloading browsers
INFO     -  [06:37:06] Browser connected: http://0.0.0.0:8880/?vscodeBrowserReqId=1653062505033
INFO     -  [06:37:07] Browser connected: http://0.0.0.0:8880/

It works fine if I disable downloading the diagrams, and they display properly.

b-bittner commented 1 year ago

Do you think the PR #27 would solve this problem, too?