【问题标题】:Redirect to https using ngrok使用 ngrok 重定向到 https
【发布时间】:2020-06-12 20:10:26
【问题描述】:

您好,我正在使用 ngrok 为我的 Web 应用程序提供服务,该应用程序托管在我的机器上运行的 Apache tomcat 中。我正在按照 commamd 运行 ngrok

ngrok tls -region=us -hostname secure.example.com -key mydoamin.key -crt mydoamin.crt 80

它在 HTTPS 中运行良好,但是当我使用 http 访问我的域时,它显示 Tunnel secure.example.com 未找到。我认为通过使用 tls 它只是公开 https 我想要的是将用户从 HTTP 重定向到 HTTPS。我可以使用 ngrok 实现这一点吗?

【问题讨论】:

    标签: ngrok


    【解决方案1】:

    希望您已经找到解决问题的方法。
    这是我的解决方案。
    要使用它,您必须拥有您的证书。

    ngrok.yml

    authtoken: <your token>
    region: <your region>
    tunnels:
       <name-https>:
       addr: 8443
       crt: path/to/cert/cert.pem
       key: path/to/key/key.pem
       host_header: "rewrite"
       proto: tls
       hostname: www.myexample.test
    <name-https>:
       addr: 80
       proto: http
       bind-tls: false
       hostname: www.myexample.test
    

    导航到目录/etc/apache2/sites-available并创建一个新文件nano example.conf

    <VirtualHost *:80>
        ServerName myexemple
        Redirect permanent / https://www.myexample.test
    </VirtualHost>
    <VirtualHost *:8443>
         ServerName <servername>
         DocumentRoot /var/www/html/<your-project>
    
         ErrorLog ${APACHE_LOG_DIR}/error.log
         CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

    全部保存并启动命令:

    a2ensite example.conf
    systemctl reload apache2
    

    到达ngrok.yml 文件的位置并使用以下命令启动它:

    ngrok start --all
    

    试试看,玩得开心:)

    【讨论】:

      猜你喜欢
      • 2020-07-12
      • 2014-10-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-18
      • 1970-01-01
      • 2012-12-11
      • 1970-01-01
      相关资源
      最近更新 更多