Appwrite Self-Hosted SDK Endpoint and Reverse-Proxy TLS: Which Hostname Must Match?
0 reputation · 07 Jul 2023, 01:55 UTC
0 reputation · 07 Jul 2023, 01:55 UTC
In a self-hosted Appwrite deployment, TLS is normally terminated by an external reverse proxy while the Appwrite containers serve plain HTTP on the internal network. SDK clients connect to the endpoint URL configured for the project and validate the presented certificate against that URL's hostname using the underlying HTTP client's default trust store.
The unresolved part is the exact contract at that boundary. If the endpoint is https://app.example.com/v1, the certificate's Subject Alternative Name must cover app.example.com, and the DNS record must resolve to the proxy rather than to a container address. Changing the endpoint after installation appears to require coordinated updates to DNS, the proxy server block, and the Appwrite environment configuration, but the failure modes overlap: a hostname mismatch and an unresolved record can both surface as a failed SDK request.
32275 reputation · 07 Jul 2023, 03:31 UTC
When a self‑hosted Appwrite deployment terminates TLS on an external reverse proxy, the certificate presented by that proxy must include the hostname that SDK clients use in the endpoint URL. If the SDK is configured to call https://app.example.com/v1, the Subject Alternative Name (SAN) of the proxy’s certificate must contain app.example.com (or a wildcard that covers it). The internal hostname or IP that the Appwrite containers use—such as appwrite.internal or 172.18.0.2—does not need to appear in the SAN.
The only supported path for self‑signed certificates is to add the CA that signed the proxy’s cert to the client’s trust store. Appwrite SDKs do not provide a configuration option to skip or override certificate verification.
# Linux (Debian/Ubuntu)
sudo cp my-proxy-ca.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
# macOS
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain my-proxy-ca.crt
openssl s_client -connect app.example.com:443 -showcerts
Check that the SAN includes app.example.com.
When a client cannot resolve the SDK endpoint, the connection attempt fails before any TLS handshake. Typical exceptions include UnknownHostException or the string "Name or service not known". In contrast, a TLS handshake failure—caused by a hostname mismatch or an untrusted cert—emits an SSL/TLS exception such as SSLHandshakeException or the message "CERTIFICATE_VERIFY_FAILED".
To test this distinction:
https://bogus.example.com) and record the error.
Examining the exception class or the error string in the SDK log will tell you whether the problem is DNS resolution or TLS verification.
If you are using a wildcard certificate or SNI with multiple hostnames, let me know the exact SAN entries you have configured. That will help confirm whether all SDK aliases are covered.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.