顯示具有 ngrok 標籤的文章。 顯示所有文章
顯示具有 ngrok 標籤的文章。 顯示所有文章

星期二, 5月 19, 2020

Building private and cheaper ngrok-like tunnels

  • In mrvm.net, you can cost USD$4 / year for 1 IPv4 address and 20 ports. In my case, 198.204.227.x 21001 ~ 21020.
  • The ssh for mrvm.net is using another port. So you can control your VPS like ssh user@198.204.227.x -p 21021.
  • In noip.com, you can register 3 free domain names like abc.hopto.org or xyz.ddns.net.
  • Using inlets, you can expose your intranet service on the cloud:
    • VPS
      • export token=$(head -c 16 /dev/urandom | sha1sum | cut -d" " -f1)
      • inlets server --port=21001 --token=$token
    • DEV
      • python -m SimpleHTTPServer 8000 (or your service)
      • inlets client --remote=abc.hopto.org:21001 --upstream=http://localhost:8000 --token=...
    • Client
      • curl http://abc.hopto.org:21001

星期六, 8月 25, 2018

Serveo, Ngrok alternative

Ngrok 非常好用,不過就是免費僅限一個,也要安裝稍嫌麻煩。若是臨時在 Linux 上要用此功能,倒是可考慮免安裝的 Serveo,只需打一行指令:
  • ssh -R 80:localhost:3000 serveo.net
如果順利,就能把本機的 3000 曝露到網際網路上,外界可訪問的主機名稱會出現在這指令的回應中。一種更厲害的用法:
  • ssh -R abc:80:localhost:3000 serveo.net
理想中可固定外界可訪問的主機名稱為 abc.serveo.net,如果沒跟別人撞名的話。

[2019/01/07]
想保持較長期的連線,需增加一個參數:
  • ssh -o ServerAliveInterval=60 -R abc:80:localhost:3000 serveo.net

星期五, 3月 02, 2018

ngrok + NextCloud + WebDAV + cURL

過去常在用 SCP + bakop.com 做為沒有圖形介面、沒有 VPN 時的抓檔來源,但畢竟是外部資源,用得不太安心。雖然以前也對 OwnCloud 下過功夫研究,但苦於必須有圖形介面瀏覽器限制,這次終於有突破:
  • 檔案分享-NextCloud
  • 指令存取-WebDAV + cURL
  • 內網外露-ngrok
其實公司早就在推 NextCloud,但並非網管,我一直試不成功。這次差別是我自己在內網用 docker 開了有絕對管理權限的一台新的,才知原來整合 LDAP 之後,各使用者有個 UUID 代表 UserName,並不等於登入帳號,所以取檔案大約像這樣:
  • curl -u 'user:pass' -O http://nc.acme.com/remote.php/dav/files/UUID/path/to/file
[2018/03/14]
原來 UUID 還是可以改的,不至於太難用,可參考 Internal Username 這段。

[2018/03/30]
ngrok 取來的主機名稱可以保留蠻久的,直到最近一次斷電。因為重新連上一定會換名字,每次都要進 config/config.php 改 trusted_domain 也實在麻煩,尤其是 docker 裡面連 vi 都沒有。一個修改訣竅是:
  • 'trusted_domains' =>
  • array (
  • 0 => '*.ngrok.io',
  • ),
另外提到在 docker 裡面不容易編輯 config.php,可以運用 occ 這個工具:
  • ./occ config:system:set 0 --value=*.ngrok.io
  • ./occ config:system:get
[2018/04/04]
單開一組帳密給外人使用似乎是管理者的特權,那我們一般小老百姓呢?也是可以在自己的管理範圍內開出共享目錄,以 http://nc.acme.com/s/<shareLink> 允許讀寫、不設密碼保護為例,上傳:
  • curl -u '<shareLink>:' -T <fileName> http://nc.acme.com/public.php/webdav/ [--progress-bar -o /dev/null]
下載:
  • curl -u '<shareLink>:' -O http://nc.acme.com/public.php/webdav/<fileName>
查詢目錄內容:
  • curl -u '<shareLink>:' -X PROPFIND http://nc.acme.com/public.php/webdav/ | grep -o '<d:href>[^<]*</d:href>'
[2018/09/06]
共享匿名個別檔案有些不同:
  • curl http://nc.acme.com/s/<shareLink>/download -o <fileName>