You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: knowledgebase/enabling-ssl-with-lets-encrypt.md
+98-21Lines changed: 98 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,86 +5,163 @@ date: 2024-12-11
5
5
6
6
The following steps can be used to enable SSL for a single ClickHouse Server using [Let's Encrypt](https://letsencrypt.org/), a free, automated, and open Certificate Authority (CA) designed to make it easy for anyone to secure their websites with HTTPS. By automating the certificate issuance and renewal process, Let's Encrypt ensures websites remain secure without requiring manual intervention.
7
7
8
-
**We assume ClickHouse has been installed at the standard package locations in the following guide. We use the domain `product-test-server.clickhouse.com` for all examples. Substitute your domain accordingly.**
8
+
:::note
9
+
We assume ClickHouse has been installed at the standard package locations in the following guide. We use the domain `product-test-server.clickhouse-dev.com` for all examples. Substitute your domain accordingly.
10
+
:::
9
11
12
+
1. Verify you have a DNS `A` or `AAAA` record pointing to your server. This can be achieved using the Linux tool `dig.` For example, the response for `product-test-server.clickhouse-dev.com` if using the Cloudflare DNS server `1.1.1.1`:
10
13
11
-
1. Verify you have a DNS `A` or `AAAA` record pointing to your server. This can be achieved using the Linux tool `dig.` For example, the response for `product-test-server.clickhouse.com` if using the Cloudflare DNS server `1.1.1.1`:
product-test-server.clickhouse-dev.com. 300 IN A 34.248.59.9
33
+
34
+
;; Query time: 52 msec
35
+
;; SERVER: 1.1.1.1#53(1.1.1.1) (UDP)
36
+
;; WHEN: Thu Dec 12 09:37:33 UTC 2024
37
+
;; MSG SIZE rcvd: 83
18
38
```
19
39
20
-
Notice the section,
40
+
Notice the section below confirming the presence of an A record.
21
41
22
42
```bash
23
-
24
-
43
+
;; ANSWER SECTION:
44
+
product-test-server.clickhouse-dev.com. 300 IN A 34.248.59.9
25
45
```
26
46
27
-
Confirming the presence of an A record.
28
-
29
47
2. Open port 80 on your server. This port will be used for automatic certificate renewal using the ACME protocol with certbot. For AWS, this can be achieved by [modifying the instance's associated Security Group](https://repost.aws/knowledge-center/connect-http-https-ec2).
If you like Certbot, please consider supporting our work by:
88
+
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
89
+
* Donating to EFF: https://eff.org/donate-le
43
90
```
44
91
45
92
:::note
46
-
If you don't have a web server running on your server, use (1) so Certbot can use a standalone temporary web server.
93
+
We don't have a web server running on our server, so use (1) allowing Certbot to use a standalone temporary web server.
47
94
:::
48
95
49
-
Enter the full domain name of your server e.g. `product-test-server.clickhouse.com` when requested.
96
+
Enter the full domain name of your server e.g. `product-test-server.clickhouse-dev.com` when requested.
50
97
51
-
::note
98
+
:::note
52
99
Let's Encrypt has a policy of not issuing certificates for certain types of domains, such as public cloud provider-generated domains (e.g., AWS *.compute.amazonaws.com domains). These domains are considered shared infrastructure and are blocked for security and abuse prevention reasons.
This command sets up a cron job to automate the management of Let's Encrypt SSL certificates for a ClickHouse server. It runs every minute as the root user, copying the .pem files from the Let's Encrypt directory to the ClickHouse server's configuration directory, but only if the files have been updated. After copying, the script adjusts the ownership of the files to the clickhouse user and group, ensuring the server has the required access. It also sets secure read-only permissions (`chmod 400`) on the copied files to maintain strict file security. This ensures that the ClickHouse server always has access to the latest SSL certificates without requiring manual intervention, maintaining security and minimizing operational overhead.
62
111
63
112
6. Configure the use of these certificates in clickhouse-server.
For this last step to work you may need to ensure port 8443 is accessible e.g. included in your Security Group in AWS. Alternatively, if you only want to access ClickHouse from the server, modify your hosts file i.e.
145
+
146
+
```bash
147
+
echo "127.0.0.1 product-test-server.clickhouse-dev.com" | sudo tee -a /etc/hosts
148
+
```
87
149
150
+
:::warning
151
+
If you open connections from wildcard addresses, make sure that at least one of the following measures is applied:
88
152
153
+
- server is protected by firewall and not accessible from untrusted networks;
154
+
- all users are restricted to a subset of network addresses (see users.xml);
155
+
- all users have strong passwords, only secure (TLS) interfaces are accessible, or connections are only made via TLS interfaces.
156
+
- users without passwords have read-only access.
89
157
90
-
```
158
+
See also: https://www.shodan.io/search?query=clickhouse
159
+
160
+
The blog [Building single page applications with ClickHouse](https://clickhouse.com/blog/building-single-page-applications-with-clickhouse-and-http) can be used as guidance for securing public instances.
161
+
:::
162
+
163
+
The following should also work if connecting from the local machine on which ClickHouse is running. To connect via `product-test-server.clickhouse-dev.com` open port 9440 in your:
0 commit comments