Skip to content

Add automatic TLS certificate support via Let's Encrypt#3

Merged
hrntknr merged 6 commits intomainfrom
auto-tls
Aug 17, 2025
Merged

Add automatic TLS certificate support via Let's Encrypt#3
hrntknr merged 6 commits intomainfrom
auto-tls

Conversation

@hrntknr
Copy link
Copy Markdown
Member

@hrntknr hrntknr commented Aug 17, 2025

Summary

  • Add automatic TLS certificate provisioning using Let's Encrypt ACME protocol
  • Change default ports from 8081 to 80 (HTTP) and 443 (HTTPS) for standard web service behavior
  • Implement HTTP to HTTPS redirect when TLS is enabled
  • Add new environment variables for TLS configuration
  • Update documentation and examples to reflect new defaults
  • Upgrade Go dependencies to latest versions

New Environment Variables

  • TLS_HOST: Host name for automatic TLS certificate generation
  • TLS_LISTEN: Address to listen on for HTTPS (default: :443)
  • TLS_DIRECTORY_URL: ACME directory URL for certificates (default: Let's Encrypt production)

- Change default port from 8081 to 80 for HTTP and 443 for HTTPS
- Add TLS_HOST, TLS_LISTEN, and TLS_DIRECTORY_URL environment variables
- Implement autocert manager for automatic certificate provisioning
- Add HTTP to HTTPS redirect when TLS is enabled
- Update documentation and examples to reflect new defaults
- Update dependencies to latest versions
@hrntknr hrntknr requested a review from Copilot August 17, 2025 15:17

This comment was marked as outdated.

- Add getEnvBoolWithDefault helper function to parse boolean environment variables
- Add tlsAcceptTOS flag and TLS_ACCEPT_TOS environment variable
- Update autocert.Manager to use configurable TOS acceptance instead of automatic acceptance
- Allows users to explicitly control whether to accept ACME terms of service
@hrntknr hrntknr requested a review from Copilot August 17, 2025 15:27

This comment was marked as outdated.

- Add proper goroutine synchronization with WaitGroup
- Implement graceful shutdown for both HTTP and HTTPS servers
- Move server logging to after server setup for better clarity
- Add context-based shutdown with 5-second timeout
@hrntknr hrntknr requested a review from Copilot August 17, 2025 15:34

This comment was marked as outdated.

@hrntknr hrntknr requested a review from Copilot August 17, 2025 15:38

This comment was marked as outdated.

Replace error channel with proper exit coordination and error collection
to handle errors from both HTTP and HTTPS servers gracefully.
@hrntknr hrntknr requested a review from Copilot August 17, 2025 15:49

This comment was marked as outdated.

- Make exit channel buffered to prevent goroutine blocking
- Filter out http.ErrServerClosed from error reporting during graceful shutdown
- Add wg.Wait() to ensure both servers complete shutdown before returning
@hrntknr hrntknr requested a review from Copilot August 17, 2025 15:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds automatic TLS certificate support via Let's Encrypt ACME protocol, changing the application from a development-focused service to a production-ready web service with proper HTTPS support.

  • Implements automatic TLS certificate provisioning using Let's Encrypt with HTTP to HTTPS redirect
  • Changes default ports from 8081 to standard web ports (80/443) for production deployment
  • Adds new TLS configuration environment variables and updates all examples and documentation

Reviewed Changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/mcp-proxy/main.go Adds TLS server implementation with autocert manager and dual HTTP/HTTPS server setup
main.go Updates command-line flags and defaults, adds TLS configuration parameters
go.mod Updates Go dependencies to newer versions
example/docker-compose.yaml Updates port mapping from 8081 to 80
example/.mcp.json Updates URL from localhost:8081 to localhost
README.md Updates documentation with new TLS environment variables and port changes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@hrntknr hrntknr merged commit b1b68bc into main Aug 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants