Ngrok: Armbian: Difference between revisions

From AbahDoku Wiki
No edit summary
Line 1: Line 1:
==Instalasi==
==Instalasi==


atau (yang penulis gunakan untuk Linux ARM64)
Instalasi dapat dilakukan dengan cara berikut (penulis menggunakan Linux ARM64) untuk mesin Armbian Server


  wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-arm64.tgz
  wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-arm64.tgz
Line 7: Line 7:
  tar -xvf ngrok-v3-stable-linux-arm64.tgz
  tar -xvf ngrok-v3-stable-linux-arm64.tgz


pastikan sudah ada file ngrok dengan perintah
pastikan file ngrok yang di download sudah ada dengan perintah


  ls
  ls
Line 25: Line 25:
  ngrok authtoken <isi_token_disini>
  ngrok authtoken <isi_token_disini>


akan menghasilkan file seperti ini
akan menghasilkan file yang tersimpan seperti berikut ini :
  Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml
  Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml


Line 31: Line 31:
  /snap/bin/ngrok authtoken <isi_token_disini>
  /snap/bin/ngrok authtoken <isi_token_disini>


akan menghasilkan file seperti ini
akan menghasilkan file seperti ini :
  /root/snap/ngrok/91/.config/ngrok/ngrok.yml
  /root/snap/ngrok/91/.config/ngrok/ngrok.yml


Line 38: Line 38:


tunnels:
tunnels:
  ssh:
    proto: tcp
    addr: localhost:22
    host_header: localhost:22
   web:
   web:
     proto: http
     proto: http
Line 48: Line 44:


==Membuat script autorun==
==Membuat script autorun==
Agar ngrok running secara otomatis pada saat server di nyalakan atau di restart, perlu dibuat file ngrok.service
berjalan secara otomatis jika server di restart
berjalan secara otomatis jika server di restart


Line 55: Line 55:


  [Service]
  [Service]
  ExecStart=ngrok start --all --config /root/.config/ngrok/ngrok.yml
  ExecStart=/usr/bin/ngrok start --all --config=/root/.config/ngrok/ngrok.yml
  ExecReload=/bin/kill -HUP $MAINPID
  ExecReload=/bin/kill -HUP $MAINPID
  KillMode=process
  KillMode=process
Line 69: Line 69:


  systemctl enable ngrok.service
  systemctl enable ngrok.service
 
Untuk Start
hasilnya :
Created symlink /etc/systemd/system/multi-user.target.wants/ngrok.service -> /lib/systemd/system/ngrok.service.
 
Untuk start
  systemctl start ngrok.service
  systemctl start ngrok.service
Untuk Stop
Untuk Stop

Revision as of 15:31, 5 March 2023

Instalasi

Instalasi dapat dilakukan dengan cara berikut (penulis menggunakan Linux ARM64) untuk mesin Armbian Server

wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-arm64.tgz

tar -xvf ngrok-v3-stable-linux-arm64.tgz

pastikan file ngrok yang di download sudah ada dengan perintah

ls

kemudian pindahkan file ngrok ke /usr/bin

mv ngrok /usr/bin

Instalasi lain dapat dilakukan seprti ini :

apt update
apt -y install snapd
snap install ngrok

Pembuatan file yml

ngrok authtoken <isi_token_disini>

akan menghasilkan file yang tersimpan seperti berikut ini :

Authtoken saved to configuration file: /root/.config/ngrok/ngrok.yml

jika menggunakan snap dengan command berikut :

/snap/bin/ngrok authtoken <isi_token_disini>

akan menghasilkan file seperti ini :

/root/snap/ngrok/91/.config/ngrok/ngrok.yml

Menambahkan Script (Berikut adalah Contoh)

Script ini sesuai kebutuhan masing-masing, letakkan di bawah baris terakhir pada file yml

tunnels:

 web:
   proto: http
   addr: localhost:8080
   host_header: localhost:808

Membuat script autorun

Agar ngrok running secara otomatis pada saat server di nyalakan atau di restart, perlu dibuat file ngrok.service


berjalan secara otomatis jika server di restart

[Unit]
Description=ngrok
After=network.target
[Service]
ExecStart=/usr/bin/ngrok start --all --config=/root/.config/ngrok/ngrok.yml
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
IgnoreSIGPIPE=true
Restart=always
RestartSec=3
Type=simple
[Install]
WantedBy=multi-user.target

Running

systemctl enable ngrok.service

Untuk Start

systemctl start ngrok.service

Untuk Stop

systemctl stop ngrok.service

Running yg lain

Jika di install menggunakan snap

/snap/bin/ngrok authtoken <your_auth_token>
/snap/bin/ngrok help
/snap/bin/ngrok http 80


Contoh2 lain

ngrok http 80                    # secure public URL for port 80 web server
ngrok http -subdomain=baz 8080   # port 8080 available at baz.ngrok.io
ngrok http foo.dev:80            # tunnel to host:port instead of localhost
ngrok http https://localhost     # expose a local https server
ngrok tcp 22                     # tunnel arbitrary TCP traffic to port 22
ngrok tls -hostname=foo.com 443  # TLS traffic for foo.com to port 443
ngrok start foo bar baz          # start tunnels from the configuration file

Referensi


Pranala Menarik