Report this

What is the reason for this report?

How to host my webpage using https or a domain

Posted on November 4, 2025

Hey, I am a beginner in the networking world, and I would like to host my HTML-JS webpage in DigitalOcean. I bought a web-hosting server with SSH access to install the packages needed to run my webpage.

So far, I have installed nginx and added my files to /var/www/html folder, then updated the /etc/nginx/sites-available/default to be something like the following:

server {
    listen 80 default_server;
    listen [::]:80 default_server;

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

    server_name _;

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

Now it seems that I can access my webpage in http://ip of the DigitalOcean. I would like to do two things: one to access it via https://ip or using a domain name instead. Any ideas on how I can do these two things will be really helpful and welcomed. }



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya

Great job getting your webpage up and running on nginx.

For HTTPS, you’ll need an SSL certificate. Here’s the thing though - you can’t get a proper SSL certificate for just an IP address. SSL certificates are issued for domain names, not IPs. So you’ll actually need to get a domain name first before you can set up HTTPS properly.

Once you have a domain, the easiest way to get HTTPS working is using Let’s Encrypt (it’s free!) with a tool called Certbot. Here’s how:

Install Certbot:

sudo apt update
sudo apt install certbot python3-certbot-nginx

Get your certificate and auto-configure nginx:

sudo certbot --nginx -d yourdomain.com -d www.yourdomain.com

Certbot will automatically modify your nginx config to enable HTTPS and even set up auto-renewal!

2. Using a Domain Name

You’ll need to:

a) Buy a domain from a registrar like Namecheap, Google Domains, or any other provider you prefer.

b) Point your domain to your server by adding an A record in your domain’s DNS settings:

  • Type: A
  • Name: @ (for root domain) or www (for www subdomain)
  • Value: Your DigitalOcean server’s IP address
  • TTL: 3600 (or whatever default they suggest)

c) Update your nginx config to use your domain name:

server_name yourdomain.com www.yourdomain.com;

d) Reload nginx:

sudo nginx -t  # Test the config first
sudo systemctl reload nginx

DNS changes can take a few minutes to a few hours to propagate, so be patient!

Once your domain is working, then run the Certbot command I mentioned above, and you’ll have HTTPS working too.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.