【问题标题】:How to correctly expose a docker server with ngrok?如何使用 ngrok 正确公开 docker 服务器?
【发布时间】:2020-10-10 05:57:45
【问题描述】:

我的机器上正在运行 docker 安装,我可以在浏览器上通过转到 mysite.local(定义为映射到 hosts 文件中的 127.0.0.1)访问该站点

当我运行 ngrok http mysite.local 时,它工作正常,但是当我打开 http://random_id.ngrok.io 链接时

  • ngrok 控制台显示:

GET / 301 永久移动

  • 我收到 NET::ERR_CERT_COMMON_NAME_INVALID 错误,如果我点击 advanced->proceed to... http://random_id.ngrok.io(不安全),它只会显示

隧道www.random_id.ngrok.io 未找到

.htaccess 中的这条规则毫无价值,尽管我觉得它看起来不错

RewriteCond %{HTTP_HOST} !^mysite.local
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]

更新 ngrok http -host-header=rewrite mysite.local 似乎确实有效,但是: css 和其他资产加载失败(.htaccess 中唯一与 css 相关的规则是:AddType text/css .chunk.css AddType text/css .css

【问题讨论】:

    标签: docker ngrok


    【解决方案1】:

    看起来重写规则我的问题。

    您的规则规定:

    如果http主机mysite.local开头, 然后重定向到https://www.HOST/[...]

    我建议完全删除重写规则使用 ngrok 的 http host header rewrite 功能:

    ngrok http -host-header=rewrite mysite.local
    

    【讨论】:

    • 它似乎确实有效。但是 css 和其他资源无法加载(.htaccess 中唯一与 css 相关的规则是:AddType text/css .chunk.css AddType text/css .css)
    猜你喜欢
    • 2021-06-19
    • 2018-12-27
    • 1970-01-01
    • 2019-03-29
    • 1970-01-01
    • 2019-11-10
    • 2017-09-21
    • 1970-01-01
    • 2018-10-07
    相关资源
    最近更新 更多