为什么ngrok尝试重定向到https方案?

问题描述 投票:0回答:1

我有一个 http 服务器,仅在

http
方案上运行(无 SSL)。如果我通过 http://localhost:80 在本地访问该站点(请注意,不支持 https://localhost:80),一切正常。我决定仅使用
http
方案通过 ngrok 从外部访问该网站。所以我使用以下命令启动了 ngrok:

ngrok http 80 --scheme http

Ngrok 成功启动,仅向我提供一个

http
链接,当粘贴到浏览器中时,该链接会重定向到
https
方案。由于
https
未启用,ngrok 给了我一个错误
ERR_NGROK_3200

那么重定向到

https
是预期的行为吗?如何明确强制 ngrok 停止重定向到
https

$ ngrok --version
ngrok version 3.4.0
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy

附注以下是 CURL GET 命令的一部分:

*   Trying 3.125.223.134:80...
* Connected to *****************.ngrok-free.app (*.***.***.134) port 80 (#0)
> GET / HTTP/1.1
> Host: *****************.ngrok-free.app
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Cache-Control: no-store, no-cache, must-revalidate
< Content-Type: text/html; charset=UTF-8
< Date: Wed, 29 Nov 2023 15:17:09 GMT
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Ngrok-Trace-Id: 854d49a42c0fb1e8f7e4cf84f872af30
< Pragma: no-cache
< Server: Apache/2.4.52 (Debian)
< Set-Cookie: PHPSESSID=1c8a7c470af71b572c5e437ce391a3a8; path=/
< Vary: Accept-Encoding,User-Agent
< X-Powered-By: PHP/7.3.33
< Transfer-Encoding: chunked

看来不是ngrok 进行了重定向,而是浏览器。我尝试了 Chrome 和 Firefox,两者的行为方式相同 - 重定向到 https。

ngrok
1个回答
0
投票

也许这解释了为什么浏览器重定向到 https - https://help.dreamhost.com/hc/en-us/articles/360025832811--dev-and-app-domains-force-HTTPS-by-default

看起来由于ngrok的域名以.app结尾,所以浏览器总是重定向到

https

© www.soinside.com 2019 - 2024. All rights reserved.