Ngrok: Armbian: Difference between revisions

From AbahDoku Wiki
No edit summary
m 23 revisions imported
 
(19 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Instalasi==
==Instalasi==


atau (yang penulis gunakan untuk Linux ARM64)
Saat tulisan ini dibuat, penulis menggunakan [[Armbian]] Linux Server ARM64 Bullseye untuk mesin [[STB B860H V2.1.]].
 
Instalasi Ngrok dapat dilakukan dengan cara berikut :
  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
tar -xvf ngrok-v3-stable-linux-arm64.tgz
pastikan sudah ada file ngrok dengan perintah


pastikan file ngrok sudah berhasil di download :
  ls
  ls
kemudian extract dengan command berikut :
tar -xvf ngrok-v3-stable-linux-arm64.tgz


kemudian pindahkan file ngrok ke /usr/bin
kemudian pindahkan file ngrok ke folder /usr/bin
 
mv ngrok /usr/bin
mv ngrok /usr/bin
 
Instalasi lain dapat dilakukan seprti ini :


Instalasi dengan caara lain dapat dilakukan seperti ini :
  apt update
  apt update
  apt -y install snapd
  apt -y install snapd
  snap install ngrok
  snap install ngrok


==Pembuatan fail yml==
==Membuat file yml==


  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


jika menggunakan snap dengan command berikut :
jika menggunakan snap dengan command berikut :
  /snap/bin/ngrok authtoken <your_auth_token>
  /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


==Menambahkan Script (Berikut adalah Contoh)==
==Menambahkan Script (Berikut adalah Contoh)==
Script ini sesuai kebutuhan masing-masing, letakkan di bawah baris terakhir pada file yml
Script ini sesuai kebutuhan masing-masing, letakkan di bawah baris terakhir pada file yml


tunnels:
tunnels:
  ssh:
  web:
    proto: tcp
    proto: http
    addr: localhost:22
    addr: localhost:80
    host_header: localhost:22
    host_header: localhost:80
  web:
    proto: http
    addr: localhost:8080
    host_header: localhost:808


==Membuat script autorun==
==Membuat script autorun==
berjalan secara otomatis jika server di restart


Agar ngrok running secara otomatis pada saat server di nyalakan atau di restart, perlu dibuat file ngrok.service
nano /lib/systemd/system/ngrok.service
yang berisi script sebagai berikut :
  [Unit]
  [Unit]
  Description=ngrok
  Description=ngrok
  After=network.target
  After=network.target
  [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 64: Line 56:
  RestartSec=3
  RestartSec=3
  Type=simple
  Type=simple
  [Install]
  [Install]
  WantedBy=multi-user.target
  WantedBy=multi-user.target
Line 71: Line 62:


  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
  systemctl stop ngrok.service
  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==
==Referensi==


* https://snapcraft.io/install/ngrok/ubuntu
* https://snapcraft.io/install/ngrok/debian
* https://ngrok.com/download
* https://ngrok.com/download
==Pranala Menarik==
* [[ngrok]]

Latest revision as of 22:47, 19 November 2024

Instalasi[edit]

Saat tulisan ini dibuat, penulis menggunakan Armbian Linux Server ARM64 Bullseye untuk mesin STB B860H V2.1.. Instalasi Ngrok dapat dilakukan dengan cara berikut :

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

pastikan file ngrok sudah berhasil di download :

ls

kemudian extract dengan command berikut :

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

kemudian pindahkan file ngrok ke folder /usr/bin

mv ngrok /usr/bin

Instalasi dengan caara lain dapat dilakukan seperti ini :

apt update
apt -y install snapd
snap install ngrok

Membuat file yml[edit]

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)[edit]

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

tunnels:
  web:
    proto: http
    addr: localhost:80
    host_header: localhost:80

Membuat script autorun[edit]

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

nano /lib/systemd/system/ngrok.service

yang berisi script sebagai berikut :

[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[edit]

systemctl enable ngrok.service

Untuk Start

systemctl start ngrok.service

Untuk Stop

systemctl stop ngrok.service

Referensi[edit]