Securing your Oxy deployment with proper authentication is essential, especially when deployed on a cloud environment. This step is optional but highly recommended for cloud deployments.

1

Choose Authentication Method

Decide which authentication method to use based on your requirements:

  • Basic Auth: Simple username/password authentication, suitable for simple deployments
  • OAuth2: More advanced authentication with third-party providers like Google, GitHub, etc.
2

Configure Authentication

Follow the instructions for your chosen authentication method:

Configure Caddy for basic authentication by updating your Caddyfile:

# Generate password hash
caddy hash-password
# Enter your password when prompted

Then update your Caddyfile:

your-domain.com {
  basicauth {
    <username> <hashed_password>
  }
  reverse_proxy localhost:8080
}

Replace <username> with your desired username and <hashed_password> with the hash generated by caddy hash-password. For more details on Caddy’s basic authentication, see the Caddy basic_auth documentation.

For example, with username “Bob” and password “hiccup”:

your-domain.com {
  basicauth {
    Bob $2a$14$Zkx19XLiW6VYouLHR5NmfOFU0z2GTNmpkT/5qqR7hx4IjWJPDhjvG
  }
  reverse_proxy localhost:8080
}

Apply the changes:

sudo systemctl reload caddy
3

Test Authentication

Test that your authentication is working correctly:

# Using curl to test basic auth
curl -u username:password https://your-domain.com

# Or test by accessing in a browser

Make sure you can access your Oxy deployment only after successful authentication.

4

Set Up Automatic Updates (Optional)

For automatic updates, you can set up a cron job:

# Update Oxy every day at midnight and restart the service
UPDATE_OXY_CRON="0 0 * * * curl --proto '=https' --tlsv1.2 -LsSf https://raw.githubusercontent.com/oxy-hq/oxy/refs/heads/main/install_oxy.sh | bash && cd ~/your-oxy-project && git pull origin main && sudo systemctl restart oxy"
(crontab -l 2>/dev/null | grep -v -F "$UPDATE_OXY_CRON"; echo "$UPDATE_OXY_CRON") | crontab -

Congratulations! Your Oxy deployment is now complete and secured with authentication.