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

    • 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
    • How to build a high-performance private photo cloud with Immich and TrueNAS SCALE
    • How to Build an Endgame Local AI Agent Setup Using an 8-Node NVIDIA Cluster with 1TB Memory
    • How to Master Windows Event Logs to Level Up Your Cybersecurity Investigations and SOC Career
    • How to Build Ultra-Resilient Databases with Amazon Aurora Global Database and RDS Proxy for Maximum Uptime and Performance
    • How to Build Real-Time Personalization Systems Using AWS Agentic AI to Make Every User Feel Special
    • How to Transform Your Windows 11 Interface into a Sleek and Modern Aesthetic Masterpiece
    • How to Understand Google’s New TPU 8 Series for Massive AI Training and Inference
    • How to Level Up Your PC Gaming Experience with the New Valve Steam Controller and Its Advanced Features
    • Is it Time to Replace Nano? Discover Fresh, the Terminal Text Editor You Actually Want to Use
    • How to Design a Services Like Google Ads
    • How to Fix 0x800ccc0b Outlook Error: Step-by-Step Guide for Beginners
    • How to Fix NVIDIA App Error on Windows 11: Simple Guide
    • Inilah Usia Ideal Anak Masuk SD: 6 Tahun atau 7 Tahun atau 8 Tahun?
    • Cara Daftar Sekolah Maung 2026
    • Anak 6 Tahun Bisa Daftar SD! Kuota Prioritas Tetap Usia 7 Tahun?
    • Apa itu Pemetaan Calon Murid Baru di SPMB Jabar 2026, PCMB Bisa Pilih 1 atau 2 Jalur? Berapa Sekolah?
    • Ini Rekomendasi 15 SMA Swasta Terbaik di Bandung 2026
    • 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
    • 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