Refactor ssl management for nginx