Skip to content

MySQL Provider HTTP/HTTPS Proxy Support #229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 2, 2025
Merged

Conversation

mailjunze
Copy link
Contributor

MySQL Provider HTTP/HTTPS Proxy Support

Overview

This document describes the implementation of HTTP/HTTPS proxy support in the MySQL Terraform provider.

Implementation Details

The MySQL provider has been updated to support HTTP and HTTPS proxies in addition to the existing SOCKS proxy support. This enhancement allows users to connect to MySQL databases through corporate proxies that use HTTP/HTTPS protocols.

Changes Made

  1. Proxy URL Validation:

    • The provider now accepts proxy URLs with http:// and https:// schemes
    • The validation regex has been updated to include these schemes: ^(socks5h?|http|https)://.*:\d+$
  2. Proxy Dialer Implementation:

    • The makeDialer function has been enhanced to handle HTTP/HTTPS proxy URLs
    • When an HTTP/HTTPS proxy is detected, it logs the proxy type and uses the appropriate dialer
  3. Environment Variables:

    • The provider respects standard proxy environment variables:
      • HTTP_PROXY/http_proxy
      • HTTPS_PROXY/https_proxy
      • ALL_PROXY/all_proxy

Usage

To use an HTTP or HTTPS proxy with the MySQL provider:

provider "mysql" {
  endpoint = "my-mysql-server:3306"
  username = "admin"
  password = "password"
  
  # HTTP proxy
  proxy = "http://proxy.example.com:8080"
  
  # Or HTTPS proxy
  # proxy = "https://proxy.example.com:8443"
}

Alternatively, you can set the proxy using environment variables:

export HTTPS_PROXY="https://proxy.example.com:8443"
terraform apply

Troubleshooting

If you encounter connection issues when using an HTTP/HTTPS proxy:

  1. Verify the proxy URL format is correct (must include port)
  2. Ensure the proxy server allows connections to the MySQL port
  3. Check if the proxy requires authentication (not currently supported in the URL)
  4. Enable debug logging with TF_LOG=DEBUG terraform apply

@petoju petoju merged commit d148317 into petoju:master May 2, 2025
15 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.

3 participants