fix(certificate-management): Fix loss of route update callback during dynamic route updates in certificate manager

This commit is contained in:
2025-05-18 23:07:31 +00:00
parent ba1569ee21
commit 8fd861c9a3
6 changed files with 422 additions and 33 deletions

View File

@ -250,10 +250,48 @@ const proxy = new SmartProxy({
});
```
## Dynamic Route Updates
When routes are updated dynamically using `updateRoutes()`, SmartProxy maintains certificate management continuity:
```typescript
// Update routes with new domains
await proxy.updateRoutes([
{
name: 'new-domain',
match: { ports: 443, domains: 'newsite.example.com' },
action: {
type: 'forward',
target: { host: 'localhost', port: 8080 },
tls: {
mode: 'terminate',
certificate: 'auto' // Will use global ACME config
}
}
}
]);
```
### Important Notes on Route Updates
1. **Certificate Manager Recreation**: When routes are updated, the certificate manager is recreated to reflect the new configuration
2. **ACME Callbacks Preserved**: The ACME route update callback is automatically preserved during route updates
3. **Existing Certificates**: Certificates already provisioned are retained in the certificate store
4. **New Route Certificates**: New routes with `certificate: 'auto'` will trigger certificate provisioning
### Route Update Best Practices
1. **Batch Updates**: Update multiple routes in a single `updateRoutes()` call for efficiency
2. **Monitor Certificate Status**: Check certificate status after route updates
3. **Handle ACME Errors**: Implement error handling for certificate provisioning failures
4. **Test Updates**: Test route updates in staging environment first
## Best Practices
1. **Always test with staging ACME servers first**
2. **Set up monitoring for certificate expiration**
3. **Use meaningful route names for easier certificate management**
4. **Store static certificates securely with appropriate permissions**
5. **Implement certificate status monitoring in production**
5. **Implement certificate status monitoring in production**
6. **Batch route updates when possible to minimize disruption**
7. **Monitor certificate provisioning after route updates**