Showing posts with label cloudflare. Show all posts
Showing posts with label cloudflare. Show all posts

Wednesday, 25 June 2025

config php untuk online dan lokal

 <?php

unset($CFG);
global $CFG;
$CFG = new stdClass();

// Deteksi apakah akses dari cloudflared (domain online) atau lokal
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';

// Atur domain Moodle sesuai host yang digunakan
if (strpos($host, 'wan.sman2kandangan.sch.id') !== false) {
    $CFG->wwwroot = 'https://' . $host;
    $CFG->sslproxy = true;
} else {
    $CFG->wwwroot = 'http://localhost';
    $CFG->sslproxy = false;
}

// Tetap atur dataroot seperti biasa
$CFG->dataroot = '/var/moodledata'; // Ganti dengan path sebenarnya
$CFG->dbtype    = 'mariadb';             // Sesuaikan dengan config awal kamu
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';             // Ganti dengan nama database kamu
$CFG->dbuser    = 'moodleuser';         // Ganti dengan user database kamu
$CFG->dbpass    = 'password_kuat';           // Ganti dengan password-nya
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbport' => '',
  'dbsocket' => '',
  'dbcollation' => 'utf8mb4_unicode_ci',
);

// Tambahkan baris ini untuk menyelesaikan konfigurasi
require_once(__DIR__ . '/lib/setup.php');

Monday, 23 June 2025

Membuka XDA Forum dengan Cloudflare WARP

 

1. Situs XDA diblokir atau diintersepsi oleh ISP

Beberapa ISP di Indonesia memblokir sebagian situs berbasis komunitas / developer. Efeknya:

  • Koneksi gagal atau sertifikat dianggap tidak sah.

  • Hanya bisa diakses lewat VPN / DNS terenkripsi / jaringan luar.

     

    ✅ Solusi Ampuh: Gunakan Cloudflare WARP (Gratis & Aman)

    💡 WARP akan:

  • Melewati blokir ISP

  • Memperbaiki masalah "Secure Connection Failed"

  • Mudah dipasang 

     

    🔧 Cara Install Cloudflare WARP di Ubuntu (Terminal)

    Jalankan langkah berikut satu per satu:

    sudo apt install curl gnupg lsb-release -y
    curl https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
    echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list
    sudo apt update
    sudo apt install cloudflare-warp

     $ sudo apt install curl gnupg lsb-release -y
    [sudo] password for dhwan: 
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    curl is already the newest version (8.5.0-2ubuntu10.6).
    gnupg is already the newest version (2.4.4-2ubuntu17.2).
    gnupg set to manually installed.
    lsb-release is already the newest version (12.0-2).
    lsb-release set to manually installed.
    0 upgraded, 0 newly installed, 0 to remove and 27 not upgraded.
    dhwan@dhwan-Aspire-A514-51K:~$ curl https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --dearmor -o /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  1688  100  1688    0     0   1934      0 --:--:-- --:--:-- --:--:--  1933
    dhwan@dhwan-Aspire-A514-51K:~$ echo "deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list
    deb [signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ noble main
    dhwan@dhwan-Aspire-A514-51K:~$ sudo apt update
    Hit:1 https://brave-browser-apt-release.s3.brave.com stable InRelease          
    Hit:2 https://packages.microsoft.com/repos/edge stable InRelease               
    Get:3 https://pkg.cloudflareclient.com noble InRelease [2,567 B]
    Get:4 https://pkg.cloudflareclient.com noble/main amd64 Packages [458 B]
    Hit:5 http://archive.ubuntu.com/ubuntu noble InRelease                         
    Hit:6 http://security.ubuntu.com/ubuntu noble-security InRelease               
    Hit:7 http://archive.ubuntu.com/ubuntu noble-updates InRelease                 
    Hit:8 https://ppa.launchpadcontent.net/obsproject/obs-studio/ubuntu noble InRelease
    Hit:9 http://archive.ubuntu.com/ubuntu noble-backports InRelease
    Hit:10 https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble InRelease
    Hit:11 https://ppa.launchpadcontent.net/thierry-f/fork-michael-gruz/ubuntu noble InRelease
    Hit:12 https://ppa.launchpadcontent.net/xtradeb/apps/ubuntu noble InRelease
    Fetched 3,025 B in 5s (645 B/s)
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    27 packages can be upgraded. Run 'apt list --upgradable' to see them.
    N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://pkg.cloudflareclient.com noble InRelease' doesn't support architecture 'i386'
    dhwan@dhwan-Aspire-A514-51K:~$ sudo apt install cloudflare-warp
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following additional packages will be installed:
      gnupg2 libnss3-tools
    Suggested packages:
      traceroute
    The following NEW packages will be installed:
      cloudflare-warp gnupg2 libnss3-tools
    0 upgraded, 3 newly installed, 0 to remove and 27 not upgraded.
    Need to get 46.2 MB of archives.
    After this operation, 129 MB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 https://pkg.cloudflareclient.com noble/main amd64 cloudflare-warp amd64 2025.4.943.0 [45.5 MB]
    Get:2 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 gnupg2 all 2.4.4-2ubuntu17.2 [4,750 B]
    Get:3 http://archive.ubuntu.com/ubuntu noble/main amd64 libnss3-tools amd64 2:3.98-1build1 [615 kB]
    Fetched 46.2 MB in 23s (2,050 kB/s)                                            
    Selecting previously unselected package gnupg2.
    (Reading database ... 234160 files and directories currently installed.)
    Preparing to unpack .../gnupg2_2.4.4-2ubuntu17.2_all.deb ...
    Unpacking gnupg2 (2.4.4-2ubuntu17.2) ...
    Selecting previously unselected package libnss3-tools.
    Preparing to unpack .../libnss3-tools_2%3a3.98-1build1_amd64.deb ...
    Unpacking libnss3-tools (2:3.98-1build1) ...
    Selecting previously unselected package cloudflare-warp.
    Preparing to unpack .../cloudflare-warp_2025.4.943.0_amd64.deb ...
    Unpacking cloudflare-warp (2025.4.943.0) ...
    Setting up gnupg2 (2.4.4-2ubuntu17.2) ...
    Setting up libnss3-tools (2:3.98-1build1) ...
    Setting up cloudflare-warp (2025.4.943.0) ...
    Created symlink /etc/systemd/system/multi-user.target.wants/warp-svc.service → /
    usr/lib/systemd/system/warp-svc.service.
    Processing triggers for hicolor-icon-theme (0.17-2) ...
    Processing triggers for gnome-menus (3.36.0-1.1ubuntu3) ...
    Processing triggers for man-db (2.12.0-4build2) ...
    Processing triggers for desktop-file-utils (0.27-2build1) ...

     

    🔌 Setelah terinstal, aktifkan WARP: 

    warp-cli registration
    warp-cli connect
     

    =======

     

     $ warp-cli registration new
    NOTICE:

    Cloudflare only collects limited DNS query and traffic data (excluding payload)
    that is sent to our network when you have the app enabled on your device. We
    will not sell, rent, share, or otherwise disclose your personal information to
    anyone, except as otherwise described in this Policy, without first providing
    you with notice and the opportunity to consent. All information is handled in
    accordance with our Privacy Policy.

    More information is available at:
    - https://www.cloudflare.com/application/terms/
    - https://www.cloudflare.com/application/privacypolicy/

    Accept Terms of Service and Privacy Policy? [y/N] y

    Success
    dhwan@dhwan-Aspire-A514-51K:~$ warp-cli connect
    Success

     

     

    💡 Harusnya sekarang situs bisa terbuka normal tanpa error SSL lagi.


    Kalau masih belum terbuka, kemungkinan:

  • Masih ada cache error di Firefox → tekan Ctrl + Shift + R untuk hard refresh

  • Atau coba dari Private Window (Ctrl + Shift + P)

  •  

     

    🧩 Ringkasan Singkat:

    ✅ Masalah awal: Secure Connection Failed
    ✅ Penyebab: Kemungkinan pemblokiran / intersepsi oleh ISP
    ✅ Solusi: Aktifkan Cloudflare WARP

     

    🔌 Kapan WARP bisa kamu disconnect?

    Kalau kamu cuma butuh akses ke situs yang diblokir sesekali, bisa matikan WARP kapan saja:

    warp-cli disconnect
     

     

     

     

     

     

Sunday, 22 June 2025

run cloudflared

 cloudflared tunnel run laptop2

Sunday, 8 June 2025

Jalankan tunnel cloudflared otomatis

 Bagus, kamu sudah berhasil menjalankan tunnel Cloudflared! Supaya tunnel Cloudflared jalan otomatis saat login ke Ubuntu (misalnya agar Moodle di laptop kamu selalu online tanpa harus manual), kamu bisa menggunakan systemd service atau crontab @reboot. Saya sarankan pakai systemd karena lebih stabil dan bisa dikontrol lebih baik.

Berikut langkah-langkahnya untuk menggunakan systemd service:
✅ 1. Cek Lokasi cloudflared dan konfigurasi

Pastikan kamu sudah login dan punya file konfigurasinya, biasanya berada di:
~/.cloudflared/config.yml
/home/dhwan/.cloudflared/config.yml

Cek juga lokasi cloudflared:
which cloudflared
/usr/local/bin/cloudflared

✅ 2. Buat service systemd

Buat file service baru:
sudo nano /etc/systemd/system/cloudflared.service
Isi dengan:
[Unit]
Description=Cloudflared Tunnel
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/cloudflared tunnel run NAMA_TUNNEL_KAMU
Restart=on-failure
User=USERNAME_KAMU

[Install]
WantedBy=multi-user.target

Ganti bagian berikut:

    NAMA_TUNNEL_KAMU: Nama tunnel kamu, bisa dicek dari cloudflared tunnel list

    USERNAME_KAMU: Nama user Ubuntu kamu, bisa dicek pakai whoami

✅ 3. Reload, Enable dan Start servicenya
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable cloudflared
sudo systemctl start cloudflared

✅ 4. Cek status

Cek apakah tunnel sudah jalan otomatis:
sudo systemctl status cloudflared
Harusnya muncul status active (running)

✅ 5. Reboot test

Coba restart laptop dan cek apakah Moodle langsung bisa diakses via domain.



Friday, 6 June 2025

Config php moodle offline localhost dan online tunel cloudflared

<?php

unset($CFG);
global $CFG;
$CFG = new stdClass();

// Deteksi apakah akses dari cloudflared (domain online) atau lokal
$host = $_SERVER['HTTP_HOST'] ?? 'localhost';

// Atur domain Moodle sesuai host yang digunakan
if (strpos($host, 'wan.sman2kandangan.sch.id') !== false) {
    $CFG->wwwroot = 'https://' . $host;
    $CFG->sslproxy = true;
} else {
    $CFG->wwwroot = 'http://localhost';
    $CFG->sslproxy = false;
}

// Tetap atur dataroot seperti biasa
$CFG->dataroot = '/var/moodledata'; // Ganti dengan path sebenarnya
$CFG->dbtype    = 'mariadb';             // Sesuaikan dengan config awal kamu
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = 'moodle';             // Ganti dengan nama database kamu
$CFG->dbuser    = 'moodleuser';         // Ganti dengan user database kamu
$CFG->dbpass    = 'password';           // Ganti dengan password-nya
$CFG->prefix    = 'mdl_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbport' => '',
  'dbsocket' => '',
  'dbcollation' => 'utf8mb4_unicode_ci',
);

// Tambahkan baris ini untuk menyelesaikan konfigurasi
require_once(__DIR__ . '/lib/setup.php');

Saturday, 2 December 2023

Membuat Tunnel Cloudflare Situs

 I can create a new tunnel without any issue.

If you’re still getting that error, is it possible you didn’t reload systemctl (systemctl daemon-reload) when you deleted the service files, or somehow are trying to use the old tunnel still? That error sounds like that tunnel doesn’t exist at all. If you manually delete the service files, reload systemctl, and then grab the install command from the tunnel you created, it shouldn’t have any issues.

Create Tunnel Cloudflare

 

Create a tunnel

To create and manage tunnels, you will need to install and authenticate `cloudflared` on your origin server. cloudflared is what connects your server to Cloudflare’s global network.

You have the option of creating a tunnel via the dashboard or via the command line. We recommend getting started with the dashboard, since it will allow you to manage the tunnel from any machine.