Skip to content

Setting Up a Custom Domain for Bartendie Documentation

Setting Up a Custom Domain for Bartendie Documentation

Section titled “Setting Up a Custom Domain for Bartendie Documentation”

This guide provides detailed instructions for configuring your Docusaurus site to use the custom domain bartendie.com, including DNS setup, Nginx configuration, and HTTPS implementation with Let’s Encrypt.

First, you need to configure your DNS records at GoDaddy to point to your Digital Ocean droplet:

  1. Log in to your GoDaddy account
  2. Navigate to the Domain Management page
  3. Select bartendie.com
  4. Click on “DNS” or “Manage DNS”
  5. Configure the following records:

A Records (Point to your Digital Ocean droplet IP)

Section titled “A Records (Point to your Digital Ocean droplet IP)”
  • Type: A
  • Name: @ (represents the root domain)
  • Value: YOUR_DROPLET_IP (e.g., 123.456.789.10)
  • TTL: 600 seconds or 1 hour
  • Type: CNAME
  • Name: www
  • Value: bartendie.com
  • TTL: 1 hour
  • You may want to set up additional records for specific subdomains if needed
  • Consider adding MX records if you plan to use email with your domain

Note: DNS changes can take 24-48 hours to fully propagate, though they often take effect much sooner.

2. Configuring Nginx on Your Digital Ocean Droplet

Section titled “2. Configuring Nginx on Your Digital Ocean Droplet”

SSH into your Digital Ocean droplet and update the Nginx configuration to recognize and serve your domain:

Terminal window
# SSH into your droplet
ssh root@YOUR_DROPLET_IP
# Create or modify the Nginx configuration file
nano /etc/nginx/sites-available/docusaurus

Replace the contents with the following configuration:

server {
listen 80;
server_name bartendie.com www.bartendie.com;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
# Additional optional configurations
# Enable gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
# Set caching for static assets
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
expires 1d;
}
}

Save the file and ensure the configuration is linked and Nginx is restarted:

Terminal window
# Enable the site if it's not already enabled
ln -sf /etc/nginx/sites-available/docusaurus /etc/nginx/sites-enabled/
# Test the Nginx configuration for syntax errors
nginx -t
# If the test is successful, restart Nginx
systemctl restart nginx

Modify your Docusaurus configuration to use your custom domain:

  1. Edit the docusaurus.config.js file in your project:
Terminal window
nano /Volumes/Storage/belmendo/Projects/bartendie/docs-site/docusaurus.config.js
  1. Update the URL and baseURL fields:
url: 'https://bartendie.com',
baseUrl: '/',
  1. Commit and push these changes to your repository to trigger deployment.

Secure your site with HTTPS using Let’s Encrypt certificates:

Terminal window
# SSH into your Digital Ocean droplet
ssh root@YOUR_DROPLET_IP
# Install Certbot and the Nginx plugin
apt update
apt install -y certbot python3-certbot-nginx
# Obtain and configure SSL certificates
certbot --nginx -d bartendie.com -d www.bartendie.com

During the Certbot process:

  • Provide your email address for renewal notifications
  • Agree to the terms of service
  • Choose whether to redirect HTTP traffic to HTTPS (recommended for security)

Certbot will automatically modify your Nginx configuration to use the SSL certificates and set up automatic renewal.

After completing the steps above:

  1. Visit https://bartendie.com in your browser
  2. Ensure the site loads correctly and the connection is secure
  3. Test that www.bartendie.com redirects properly
  4. Verify that all site functionality works as expected

If your Docusaurus site requires environment variables (for APIs, analytics, etc.):

Add Environment Variables as GitHub Secrets

Section titled “Add Environment Variables as GitHub Secrets”
  1. Go to your GitHub repository
  2. Navigate to Settings > Secrets and variables > Actions
  3. Click “New repository secret”
  4. Add each environment variable with an appropriate name:
    • Name: ENV_VARIABLE_NAME (e.g., GOOGLE_ANALYTICS_ID)
    • Value: Your secret value
    • Click “Add secret”

Modify your GitHub Actions workflow (.github/workflows/deploy.yml) to use these environment variables during the build process:

# ... existing workflow code ...
- name: Build website
working-directory: ./docs-site
env:
GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }}
API_KEY: ${{ secrets.API_KEY }}
# Add other environment variables as needed
run: npm run build
# ... rest of workflow ...

In your Docusaurus configuration or components, access these variables using process.env:

// Example in docusaurus.config.js
googleAnalytics: {
trackingID: process.env.GOOGLE_ANALYTICS_ID,
anonymizeIP: true,
},

Let’s Encrypt certificates expire after 90 days. Certbot sets up automatic renewal, but you can manually trigger renewal:

Terminal window
certbot renew

If you make changes to your Nginx configuration:

Terminal window
nginx -t # Test configuration
systemctl reload nginx # Apply changes if test passes
Terminal window
certbot certificates

Monitor your site and check logs for issues:

Terminal window
# Nginx access logs
tail -f /var/log/nginx/access.log
# Nginx error logs
tail -f /var/log/nginx/error.log
# Let's Encrypt logs
tail -f /var/log/letsencrypt/letsencrypt.log