Try   HackMD

ngrok轉發伺服器

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →
回筆記首頁

tags: ngrok server

我們架好API(伺服器)之後,我們只能在自己的電腦或是區域網路使用API,如果希望全球都能看的話,我們需要一個轉發伺服器或是一個私有的伺服器,這裡要介紹的是轉發伺服器。

ngrok 做為一個轉發的伺服器,他可以把外界的請求轉發到你指定的Port,使用的背景原理是連接到 ngrok 雲端伺服器,將你本機指定的地址公開,再將由 ngrok 一串公開的網址來存取內容。他的優點是快速而且還提供了https的服務讓你使用上更安全,甚至你還可以設置密碼保護。

首先,先到 ngrok.com 註冊、登入後即可,接著下載 ngrok

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

執行 Ngrok http [[ip]:]port
Ex: ngrok http 8000
(Ctrl+C to quit)

Session Status                online
Account                       inconshreveable (Plan: Free)
Version                       3.0.0
Region                        United States (us)
Latency                       78.006541ms
Web Interface                 http://127.0.0.1:4040
Forwarding                    https://84c5df439d74.ngrok.io -> http://localhost:8000

Connections                   ttl     opn     rt1     rt5     p50     p90
                              0       0       0.00    0.00    0.00    0.00

如果上述的設定無法連結,官網建議增加 --host-header=localhost 下指令:ngrok http --host-header=localhost 8000

參照 https://andy6804tw.github.io/2020/04/10/gcp-gunicorn/ 使用Gunicorn將API背景執行

Author:

  • 林奇賢