Skip to content

Instantly share code, notes, and snippets.

@dirumahrafif
Created October 1, 2025 10:09
Show Gist options
  • Select an option

  • Save dirumahrafif/924c00b7c74bb13fe581f8618317d80b to your computer and use it in GitHub Desktop.

Select an option

Save dirumahrafif/924c00b7c74bb13fe581f8618317d80b to your computer and use it in GitHub Desktop.
Konfigurasi Nginx Untuk Mengarahkan Domain

Install nginx

sudo apt install nginx

cek firewall

sudo ufw app list

buka port 80

sudo ufw allow 'Nginx HTTP'

buka port 443

sudo ufw allow 'Nginx HTTPS'

enable pengaturan firewall baru

sudo ufw enable

cek pengaturan

sudo ufw status

cek status nginx

systemctl status nginx

masuk ke folder nginx

cd /etc/nginx/sites-available

Buat file konfigurasi

sudo nano nextjs-app

masukkan script

server {  
    listen 80;  
    server_name domainmu.com www.domanmu.com;  
    location / {  
        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;  
        proxy_cache_bypass $http_upgrade;  
    }  
}

buat simbolic link

sudo ln -s /etc/nginx/sites-available/nextjs-app /etc/nginx/sites-enabled

restart nginx

sudo service nginx restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment