如何让 ngrok 服务器永远运行?

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

我想让我的网站在 ngrok 24/7 上在线,但它的会话将在 2 小时后过期。有没有办法让它永远运行,或者我应该使用任何替代软件?

ngrok
3个回答
2
投票

如果您在 ngrok.com 上注册一个帐户,无论是免费还是付费,您都将拥有不受时间限制(又名“永远”)运行的隧道。


0
投票

如果你不关心域名地址的持久性并且你使用Discord并且你只想用它来测试,分享它给朋友查看你可以使用这个: https://github.com/winter-b/ngrok-bot 这是一个 Discord 机器人,每两小时执行一次 shell 命令以重启 ngrok 隧道,获取 url,并将其发送到指定的 Discord 频道。 首先创建一个 Discord 机器人,如何在这里 https://discord.com/developers/docs/intro,获取机器人令牌,将机器人放入您的 Discord 服务器,获取您要将 url 发送到的频道 ID,将settings.json 中的 discord 机器人令牌和频道 ID

在目录中运行

npm install  
npm start

它并不完美,但可以针对特定场景完成工作


0
投票

要解决这个问题,您必须先准备付费版本的ngrok,然后使用以下Python代码定义一个机器人,例如在12小时内在ngrok上重新制作您的URL。请注意,使用付费版本的 ngrok,您的 URL 不会更改,只需每 12 到 24 小时重新标记一次:

首先在你的 python 上安装“pyngrok”{pep install pyngrok}

#hears 蟒蛇鳕鱼: 导入时间 从 pyngrok 导入 ngrok

设置 Ngrok 身份验证令牌

ngrok.set_auth_token('YOUR OTHE TOKEN') #REPLACE WITH YOUR OTHE TOKEN GIVEN FROM NGROK SITE

虽然正确: # 启动 HTTP 隧道并将其绑定到带有子域的端口 8080 http_tunnel = ngrok.connect(8080, proto='http', subdomain='YOURSUBDOMAIN')

# Get the public URL for the HTTPS tunnel
public_url = http_tunnel.public_url
if http_tunnel is not None:
    # Get the public URL for the HTTP tunnel
    public_url = http_tunnel.public_url

    # Print the public URL
    print(f'Public URL: {public_url}')

    # Keep the HTTP tunnel open for 12 hours
    time.sleep(12*60*60)

    # Kill all Ngrok processes to close the tunnel
    ngrok.kill()
else:
    # If the tunnel was not created, print an error message and try again
    print('Failed to create Ngrok tunnel. Retrying...')
© www.soinside.com 2019 - 2024. All rights reserved.