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 Run Gemma Embedding Models Using Docker
    • Deploy Nginx Rootful Container with Podman
    • How to Sandboxing Browser on Linux Desktop with Flatpak
    • How to Hardening Journald on Linux Server (Fedora/AlmaLinux)
    • Block Bad USB on Linux Server with USBGuard
    • How to Secure NetworkManager on Fedora/AlmaLinux
    • How to Secure DNS and NTP in Fedora Linux
    • How to Hardening DNF on Fedora/Almalinux
    • How to Masking & Secure Daemon in Linux Server
    • How to Hardening Mount Option in Linux Server
    • How to Secure Linux Server with AIDE
    • Auditd Custom Rules & Tips
    • Securing SSH Server with fail2ban
    • Fedora Linux Firewalld Drop Zone and Rich Rules
    • How to SSH Hardening 2026
    • How to Add Password Protection to GRUB
    • Linux Kernel Hardening: Command-line Lockdown
    • Make Linux Kernel More Safe and Hardening with Sysctl Easy Way
    • 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
    • Paham Semua Keluarga Model AI Gemma 4
    • Rumor Laptop Android Ternyata Bener, Ini Daftar 4 Laptop Android dari Google!
    • LCOS Lagi Naik Daun: OS Buatan Lunduke Tembus Peringkat 12 DistroWatch dan Punya Kernel Sendiri
    • Cara Pindah Data Android ke iPhone Tanpa Reset iPhone
    • Valve: Steam Deck 2 Tetap di Develop, Meski RAM Naik Harga Gila-gilaan
    • The Rise and Fall of the Coding Holy Grail: Is Stack Overflow Just AI Fuel Now?
    • Zyphra is The Pioneer, Why Everyone is Suddenly Obsessed with AMD and Not Just Nvidia Anymore
    • Stop Trusting Your Prompts to Save Your Business Data
    • 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
    RSS Error: WP HTTP Error: A valid URL was not provided.
    ©2026 Tutorial emka | Design: Newspaperly WordPress Theme