如何通过Docker容器的https服务Kinto?

正如在Kinto文档中所写,我可以通过这种方式指定一个自定义configuration :

docker run --env-file ./kinto.env -p 8888:8888 kinto/kinto-server

此外,似乎我可以build议使用http_scheme属性的httpscheme 。

现在,如果我:

  1. KINTO_HTTP_SCHEME=https放入kinto.env文件中;
  2. 通过上面的命令运行Kinto,
  3. 转到https://example.com:8888/v1/ ;

我得到一个空白页面。

附加信息

如果我导航到http://example.com:8888/v1/ ,我会得到页面上通常的JSONconfiguration。 这个JSON还包含一个url属性https://example.com:8888/v1/ (而不是http://example.com:8888/v1/ ),所以似乎有一些事情发生: .env文件是读。 该链接是可点击的,但如果我点击它,我仍然得到一个空白页面。

这是一个错误? 我该如何解决?


笔记

这一点很重要,因为如果通过https提供页面,Chrome将不允许我提供http内容。 它完全阻止了请求,在控制台中显示了一个适当的错误: d Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure resource 'http://example.com:8888/v1/'. This request has been blocked; the content must be served over HTTPS. d Content: The page at 'https://example.com/' was loaded over HTTPS, but requested an insecure resource 'http://example.com:8888/v1/'. This request has been blocked; the content must be served over HTTPS.

Kinto说: Fetch API cannot load http://example.com:8888/v1/. Failed to start. Error: HTTP 0; TypeError: Failed to fetch(…) Fetch API cannot load http://example.com:8888/v1/. Failed to start. Error: HTTP 0; TypeError: Failed to fetch(…)

这取决于你如何运行Kinto。 pserve默认使用服务器服务器,它没有任何HTTPS支持。

备用服务器可以作为替代(例如gunicorn或uwsgi)作为pserve的替代品,方法是在.ini文件中指定它。

这里是适当的文档的指针:

  • gunicorn: http ://docs.gunicorn.org/en/latest/settings.html?highlight=ssl#ssl
  • uwsgi: http : //uwsgi-docs.readthedocs.org/en/latest/HTTPS.html

例如,独angular兽看起来像这样:

 [server:main] use = egg:gunicorn host = 0.0.0.0 port = 5900 workers = 1 worker_class = gevent 

然后configurationgevent来执行SSL:

 certfile=~/ssl/server.crt keyfile=~/ssl/server.key ssl_version=3 

对于uwsgi,您在文档中有一个默认configuration,请参阅http://kinto.readthedocs.org/en/latest/configuration/production.html?highlight = uwsgi#running-with-uwsgi

希望有所帮助。

或者,您可以使用NGINX或haproxy为您执行SSL终止。

从未使用Kinto,但从文档 :

环境variables与设置完全相同,但是它们都是大写的。 被_replace。

例如,如果定义,则从环境variablesKINTO_STORAGE_BACKEND读取kinto.storage_backend。

所以,你想在你的kinto.env文件中设置的环境variables是KINTO_HTTP_SCHEME ,而不是HTTP_SCHEME

Interesting Posts