mirror of
https://github.com/jeffcaldwellca/mkcertWeb.git
synced 2026-04-26 00:18:16 -05:00
5.8 KiB
5.8 KiB
Settings Configuration Guide
Overview
The Settings page provides a web-based interface for managing all mkcert Web UI configuration options. Settings configured through the UI are stored in config/settings.json and take precedence over environment variables defined in .env.
Features
- Tabbed Interface: Organized settings by category (Server, Authentication, Rate Limiting, Email, Monitoring, Theme)
- Persistent Storage: Settings are saved to
config/settings.jsonand persist across server restarts - Override Mechanism: Settings from the UI override
.envvalues - Security: Sensitive values (passwords, secrets) are masked when displayed and only saved when explicitly changed
- Import/Export: Backup and restore settings via JSON export/import
- Real-time Validation: Form validation before saving
Settings Categories
Server Configuration
- HTTP and HTTPS ports
- SSL domain and certificate settings
- HTTPS enable/force options
- Certificate storage paths
Authentication
- Basic Authentication: Enable/disable, username, password, session secret
- OIDC SSO: OpenID Connect integration for enterprise authentication (Azure AD, Google, Okta, etc.)
Rate Limiting
- CLI Rate Limiting: Protect certificate generation endpoints
- API Rate Limiting: General API request limits
- Auth Rate Limiting: Login attempt throttling
Email Notifications
- SMTP server configuration
- TLS/SSL settings
- From/To addresses
- Test email functionality
Certificate Monitoring
- Automatic certificate expiry checking
- Cron-based scheduling
- Warning and critical thresholds
- Email alert integration
Theme
- Default theme mode (light/dark)
- Primary color customization
Usage
Accessing Settings
- Navigate to the Settings page via the navigation menu
- Authentication is required if auth is enabled
- Click on tabs to view different setting categories
Saving Settings
- Modify desired settings in the form
- Click "Save Settings" button
- Settings are immediately saved to
config/settings.json - Some settings may require a server restart to take effect
Resetting to Defaults
- Click "Reset to Defaults" button
- Confirm the action
- All custom settings are deleted, reverting to
.envor default values
Import/Export Settings
- Export: Use the export endpoint
/api/settings/exportto download current settings as JSON - Import: POST to
/api/settings/importwith JSON data to restore settings
Technical Details
Storage Mechanism
- Settings are stored in
config/settings.json - File is created automatically on first save
- Nested object structure mirrors the application configuration
Override Priority
- Highest: Values from
config/settings.json(UI settings) - Middle: Environment variables from
.envfile - Lowest: Default values in
src/config/index.js
Configuration Loading
The config loader (src/config/index.js) performs a deep merge:
finalConfig = deepMerge(envConfig, savedSettings)
API Endpoints
GET /api/settings- Retrieve current settingsPOST /api/settings- Save settingsDELETE /api/settings- Reset to defaultsGET /api/settings/export- Export settings as JSONPOST /api/settings/import- Import settings from JSON
Security Considerations
- Sensitive fields (passwords, secrets) are sanitized before sending to client
- Masked values (
********) are not saved unless explicitly changed - Settings file is added to
.gitignoreto prevent committing sensitive data - Authentication required for settings access (if enabled)
- Rate limiting applied to settings endpoints
Migration from .env
To migrate existing .env configuration to the Settings UI:
- Start the server with your existing
.envfile - Navigate to the Settings page
- Review the pre-populated values (loaded from
.env) - Make any desired changes
- Click "Save Settings"
- Settings are now stored in
config/settings.jsonand will override.env
Restart Requirements
The following settings require a server restart to take effect:
- Server ports (HTTP/HTTPS)
- HTTPS enable/disable
- Authentication configuration
- Rate limiting windows
- Certificate monitoring schedule
Other settings (like email SMTP) are loaded dynamically by services and may not require restart.
Troubleshooting
Settings Not Saving
- Check console for error messages
- Verify write permissions on
config/directory - Check server logs for detailed error information
Settings Not Taking Effect
- Some settings require server restart
- Check that
config/settings.jsonwas created - Verify settings file is valid JSON
Lost Settings
- Check if
config/settings.jsonexists - Restore from backup using import feature
- Settings file may have been deleted or corrupted
Best Practices
- Backup Settings: Regularly export settings for backup
- Test Changes: Test critical changes (auth, ports) in development first
- Document Custom Values: Keep notes on why certain settings were changed
- Use Environment Variables for Secrets: Consider keeping sensitive data in
.env(not committed to git) and using settings UI for non-sensitive configuration - Review After Updates: Check settings page after updating the application
Development
Adding New Settings
- Add setting to
src/config/index.jsbase configuration - Add form field to
public/settings.htmlin appropriate tab - Ensure field name matches nested config path (e.g.,
email.smtp.host) - Update this documentation
Testing Settings
# Start server
npm run dev
# Test settings endpoint
curl http://localhost:3000/api/settings
# Save test settings
curl -X POST http://localhost:3000/api/settings \
-H "Content-Type: application/json" \
-d '{"server":{"port":3001}}'
# Reset settings
curl -X DELETE http://localhost:3000/api/settings