Deploy a Website to a VPS with Nginx and SSL

Connect a domain, set up Nginx to serve static files, then enable HTTPS with an SSL certificate.

Deploy flow overview

Deploy is the process of moving a website from your own computer to a server so others can access it. The flow is simple: point the domain to the server, install a web server, place the files, then enable HTTPS.

Pointing the domain

In your domain management panel, create a DNS record of type A that points to your server's IP address. For example:

terminal / code
# DNS record
# Type  Name  Value
# A     @     203.0.113.10
# A     www   203.0.113.10

Installing Nginx

Nginx's job is to receive visitor requests and send the right files:

terminal / code
sudo apt install nginx -y
sudo systemctl enable nginx
sudo systemctl start nginx

Placing the website files

Put the static files in the web directory. An example of a minimal server block configuration:

terminal / code
server {
    listen 80;
    server_name contoh.biz.id;

    root /var/www/contoh;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

Enabling SSL

An SSL certificate makes the connection encrypted so the address changes from http to https. One common approach is to use Certbot:

terminal / code
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d contoh.biz.id -d www.contoh.biz.id

Security notes

Make sure only the necessary ports are open. Update packages regularly and monitor the SSL certificate's expiry date. After deploying, test from another device to confirm the website is truly accessible to the public.

Edologia Team Writer & Practitioner — writes from real practice, not just theory.
Something not clear?

Ask via WhatsApp and we'll explain it in plain language.

Keep reading

Related Articles

Keep learning

Practice While You Learn

Need a server and full guidance to try the steps above? Ask about the package details and options first — no pressure.

Chat on WhatsApp