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 Lockdown Root & Wheel Group in Linux
    • How to Secure Sudo in Linux (Secure Sudo Logging & Timeout)
    • Make Fedora Login Safe with Authselect and Faillock
    • How Measure Linux Security Use OpenSCAP Lynis and Systemd
    • SELinux Make Nginx Break and How to Fix It Easy
    • How See Hidden SELinux Errors When Your Server Is Broken
    • How Fix SELinux Port Denied Error With Sealert Easy Guide
    • Read SELinux AVC Denial Log Simple Guide for Noob
    • How Check and Fix SELinux Block Things in Fedora Linux
    • How Actually SELinux is Work?
    • How to Install Elementary OS 8 Easy and Make It Good
    • How to Install UniFi OS Server on Ubuntu Linux Without Cloud Key
    • Top DNF5 Tips to Make Your Fedora Linux Super Fast
    • Run Local AI on Fedora 44 CPU Without Expensive GPU
    • Google Gemini Live Redesign: Works with more ‘Connected Apps’ on Android
    • A new LILYGO T3S3 ESP32-S3 with LoRA, WiFi & Bluetooth is Released only $16
    • New ESP32 Project: OpenTrafficMap ESP32-C5 C-ITS With 802.11p V2X communication
    • How to Unlock the Hidden Potential of Your Kindle with Amazing Community Plugins
    • How to Use Waze with Android Auto for the Ultimate Driving Experience
    • How to Transform Your GNOME Desktop with GNOME Prism
    • Why Your Google Maps Wear OS Navigation Fails While Using Android Auto
    • Packagist Attacked! How to Detect Hidden Malware Like This?
    • Claude Mythos Keeps Find High-severity Flaws, What You Should You Do?
    • How to Secure Your PHP Applications Against the Recent Laravel-Lang Supply Chain Attack and Credential Stealers
    • How to Protect Your Server from the LiteSpeed cPanel Plugin Privilege Escalation Vulnerability
    • Inilah 20 Kampus Swasta Terbaik di Bandung Versi EduRank 2026 untuk Referensi Kuliah Kalian
    • Inilah Syarat dan Cara Daftar Sekolah Kedinasan STPN 2026, Kuota Terbatas!
    • Inilah Cara Daftar PPKB UI 2026 Lengkap dengan Rincian Uang Pangkal Semua Jurusan S1
    • Inilah Aturan Resmi MPLS 2026 dari Kemendikdasmen, Guru dan Sekolah Wajib Catat Pedoman Lengkap Ini!
    • Inilah Cara Daftar Beasiswa S1/D4 Guru Kemendikdasmen 2026, Masa Pendaftaran Diperpanjang!
    • How to Automate Your Entire SEO Strategy Using a Swarm of 100 Free AI Agents Working in Parallel
    • How to create professional presentations easily using NotebookLM’s AI power for school projects and beyond
    • How to Master SEO Automation with Google Gemini 3.1 Flash-Lite in Google AI Studio
    • How to create viral AI video ads and complete brand assets using the Claude and Higgsfield MCP integration
    • How to Transform Your Mac Into a Supercharged AI Assistant with Perplexity Personal Computer
    RSS Error: WP HTTP Error: A valid URL was not provided.
    ©2026 Tutorial emka | Design: Newspaperly WordPress Theme