Skip to content
Tutorial emka
Menu
  • Home
  • Debian Linux
  • Ubuntu Linux
  • Red Hat Linux
Menu

Tutorial Cara Setting Nginx Server dan Websocket

Posted on October 29, 2024

Dalam dunia aplikasi yang serba cepat, update real-time seperti notifikasi langsung atau fitur chat menjadi sangat penting. WebSockets, sebuah teknologi yang memungkinkan koneksi dua arah terus-menerus antara klien dan server, menjadi kunci untuk menghadirkan pengalaman ini. Namun, untuk memastikan koneksi WebSockets berjalan lancar, Anda perlu mengatur server web Anda, seperti Nginx, dengan tepat.

https://example.comwss://example.com/live-updates

/etc/nginx/sites-available/default/etc/nginx/nginx.conf

server {
    listen 80;
    server_name example.com;

    # Konfigurasi lainnya (seperti root, index, dll.)

    location /live-updates {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
    

Penjelasan Konfigurasi:

  • proxy_passlocalhost:3000

  • proxy_http_version 1.1

  • proxy_set_header Upgrade $http_upgradeproxy_set_header Connection “upgrade”

  • Langkah 3: Merestart Nginx

    Setelah melakukan perubahan, restart Nginx untuk menerapkan konfigurasi baru. Jalankan perintah berikut:

          sudo systemctl restart nginx
        

    Recent Posts

    • How to Fix Error Code 0x80073d21 for Enhanced Speech Recognition on Windows
    • What is DNS-Persist-01? Let’s Encrypt’s New Solution for Reliable SSL Validation
    • How to Use User Accounts & System Admin on Linux Mint 23
    • What is Docker Digest Watching? Understanding the New Standard in Docker 8.2
    • What is LibreOffice Online? A Guide to the Community-Driven Cloud Office Suite
    • Lutris 0.5.21 Adds Steam Sniper Runtime & New Emulators: What’s New?
    • Wine 11.3 Released: New Features and Improvements Explained
    • How to Discover Hidden Risks in Arch AUR Packages with Taur, the New Rust Tool
    • Cosmic Desktop 1.0.8 Released: New Features and Improvements Explained
    • What is Mozilla Thunderbird 148 and its EWS Enhancements?
    • Why Ladybird Switches to Rust? Is it for Faster Browser Engine
    • What is OAC? An Introduction to the Next Generation Open Audio Codec
    • 0 A.D. Game Ends its 16-Year Alpha Phase
    • Mabox Linux 26.02 Released with New Audio Menu Features
    • WhatsApp to Add Scheduled Message Feature Soon
    • Ardour 9.1 DAW Released with Editor Fixes and MIDI Improvements Explained
    • Microsoft Removes Security Feature in Edge, Password Managers Must Know
    • MinIO Fork Launched: Open Source Community Enhances Object Storage
    • Why Ubuntu 26.04’s use OpenJDK 25 Default?
    • What New in DietPi 10.1? the Latest Lightweight SBC OS Update
    • Is It True: Microsoft Notepad Will Have Image Support?
    • KDE Plasma 6.7 Adds Desktop Switching in Overview Explained
    • What’s New in Clonezilla Live 3.3.1? Exploring the New Features and Linux Kernel 6.18 Integration
    • How to Automate Your Home Lab Using Raspberry Pi and Cron Jobs
    • KDE Plasma 6.6.1 Released with Major Stability Improvements
    • Inilah Data Pendaftar KIP Kuliah 2026 Jalur SNBP dan Bocoran Kriteria yang Lolos!
    • Inilah Game Silent Hill: Townfall, Teror Psikologis Baru yang Bakal Bikin Kalian Gemetar di Tahun 2026!
    • Inilah Trailer Mortal Kombat 2, Johnny Cage Resmi Gabung dan Siap Hadapi Shao Kahn!
    • Inilah Spesifikasi Lengkap Samsung Galaxy S26 yang Baru Meluncur, Ternyata Harganya Naik Segini!
    • Inilah Cara Mematikan MSA Xiaomi Supaya HP Nggak Lemot dan Bebas Iklan, Ternyata Langkahnya Simpel Banget!
    • Prompt AI Menyusun Script Pola Suara Karakter agar Brand Jadi Ikonik
    • Prompt AI untuk Merancang Karakter Brand yang Ikonik
    • Prompt AI Audit Konten Sesuai Karakter Brand
    • Prompt AI Merubah Postingan LinkedIn Jadi Ladang Diskusi dengan ChatGPT
    • Prompt AI: Paksa Algoritma LinkedIn Promosikan Konten Kalian
    • Apa itu Spear-Phishing via npm? Ini Pengertian dan Cara Kerjanya yang Makin Licin
    • Apa Itu Predator Spyware? Ini Pengertian dan Kontroversi Penghapusan Sanksinya
    • Mengenal Apa itu TONESHELL: Backdoor Berbahaya dari Kelompok Mustang Panda
    • Siapa itu Kelompok Hacker Silver Fox?
    • Apa itu CVE-2025-52691 SmarterMail? Celah Keamanan Paling Berbahaya Tahun 2025
    ©2026 Tutorial emka | Design: Newspaperly WordPress Theme