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.
1. DNS Configuration with GoDaddy
Section titled “1. DNS Configuration with GoDaddy”First, you need to configure your DNS records at GoDaddy to point to your Digital Ocean droplet:
- Log in to your GoDaddy account
- Navigate to the Domain Management page
- Select bartendie.com
- Click on “DNS” or “Manage DNS”
- 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
CNAME Record (For the www subdomain)
Section titled “CNAME Record (For the www subdomain)”- Type: CNAME
- Name: www
- Value: bartendie.com
- TTL: 1 hour
Additional Records (Optional)
Section titled “Additional Records (Optional)”- 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:
# SSH into your dropletssh root@YOUR_DROPLET_IP
# Create or modify the Nginx configuration filenano /etc/nginx/sites-available/docusaurusReplace 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:
# Enable the site if it's not already enabledln -sf /etc/nginx/sites-available/docusaurus /etc/nginx/sites-enabled/
# Test the Nginx configuration for syntax errorsnginx -t
# If the test is successful, restart Nginxsystemctl restart nginx3. Update Docusaurus Configuration
Section titled “3. Update Docusaurus Configuration”Modify your Docusaurus configuration to use your custom domain:
- Edit the
docusaurus.config.jsfile in your project:
nano /Volumes/Storage/belmendo/Projects/bartendie/docs-site/docusaurus.config.js- Update the URL and baseURL fields:
url: 'https://bartendie.com',baseUrl: '/',- Commit and push these changes to your repository to trigger deployment.
4. Setting Up HTTPS with Let’s Encrypt
Section titled “4. Setting Up HTTPS with Let’s Encrypt”Secure your site with HTTPS using Let’s Encrypt certificates:
# SSH into your Digital Ocean dropletssh root@YOUR_DROPLET_IP
# Install Certbot and the Nginx pluginapt updateapt install -y certbot python3-certbot-nginx
# Obtain and configure SSL certificatescertbot --nginx -d bartendie.com -d www.bartendie.comDuring 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.
5. Verify Your Setup
Section titled “5. Verify Your Setup”After completing the steps above:
- Visit https://bartendie.com in your browser
- Ensure the site loads correctly and the connection is secure
- Test that www.bartendie.com redirects properly
- Verify that all site functionality works as expected
6. Environment Variables for Docusaurus
Section titled “6. Environment Variables for Docusaurus”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”- Go to your GitHub repository
- Navigate to Settings > Secrets and variables > Actions
- Click “New repository secret”
- Add each environment variable with an appropriate name:
- Name:
ENV_VARIABLE_NAME(e.g.,GOOGLE_ANALYTICS_ID) - Value: Your secret value
- Click “Add secret”
- Name:
Update GitHub Actions Workflow
Section titled “Update GitHub Actions Workflow”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 ...Using Environment Variables in Docusaurus
Section titled “Using Environment Variables in Docusaurus”In your Docusaurus configuration or components, access these variables using process.env:
// Example in docusaurus.config.jsgoogleAnalytics: { trackingID: process.env.GOOGLE_ANALYTICS_ID, anonymizeIP: true,},7. Maintenance and Troubleshooting
Section titled “7. Maintenance and Troubleshooting”Renewing SSL Certificates
Section titled “Renewing SSL Certificates”Let’s Encrypt certificates expire after 90 days. Certbot sets up automatic renewal, but you can manually trigger renewal:
certbot renewTesting Nginx Configuration
Section titled “Testing Nginx Configuration”If you make changes to your Nginx configuration:
nginx -t # Test configurationsystemctl reload nginx # Apply changes if test passesChecking SSL Certificate Status
Section titled “Checking SSL Certificate Status”certbot certificatesMonitoring and Logs
Section titled “Monitoring and Logs”Monitor your site and check logs for issues:
# Nginx access logstail -f /var/log/nginx/access.log
# Nginx error logstail -f /var/log/nginx/error.log
# Let's Encrypt logstail -f /var/log/letsencrypt/letsencrypt.log