Skip to content

Commit 102d8f1

Browse files
Add custom SSL for Lab configuration page (#1030)
* add custom SSL configuration page * update titlecase --------- Co-authored-by: katarinasupe <[email protected]> Co-authored-by: Katarina Supe <[email protected]>
1 parent 7bb479d commit 102d8f1

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

pages/data-visualization/install-and-connect.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ Configure Memgraph Lab using the following environment variables when running it
261261
| `QUICK_CONNECT_MG_IS_ENCRYPTED` | Turn SSL on/off for quick connect | `boolean` | `false` |
262262
| `PORT` | Lab app default listening port | `integer` | `3000` |
263263
| `REQUEST_BODY_LIMIT_MB` | Limit for request body size in MB | `integer` | `20` |
264+
| `SSL_IS_ENABLED` | Enable or disable SSL | `boolean` | `false` |
265+
| `SSL_CERT_PATH` | Path to SSL certificate to be used | `string` | `./ssl/cert.pem` |
266+
| `SSL_KEY_PATH` | Path to SSL key to be used | `string` | `./ssl/key.pem` |
264267
| `STORAGE_MG_HOST` | `(Enterprise only)` Memgraph host for the Lab remote storage | `string` | |
265268
| `STORAGE_MG_PORT` | `(Enterprise only)` Memgraph port for the Lab remote storage | `number` | |
266269
| `STORAGE_MG_IS_ENCRYPTED` | `(Enterprise only)` Memgraph SSL on/off for the Lab remote storage | `boolean` | |
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
title: Custom SSL certificates
3+
description: Use your own SSL certificate to use Memgraph Lab with HTTPS protocol.
4+
---
5+
6+
## Instantiating Memgraph Lab with custom SSL certificate
7+
8+
Memgraph Lab supports using custom SSL certificates, ensuring secure communication over HTTPS. To set up
9+
SSL on Memgraph Lab you will need to configure a Dockerfile using a valid SSL certificate.
10+
11+
### Options for generating SSL certificates
12+
13+
There are various options to generate SSL certificates. Check out the steps on
14+
how to do that with [OpenSSL](#openssl) and [Let's Encrypt](#lets-encrypt).
15+
16+
17+
#### OpenSSL
18+
[OpenSSL](https://github.com/openssl/openssl) is a widely used tool for
19+
generating SSL certificates. You can create a self-signed certificate using the
20+
following commands:
21+
22+
1. Generate a private key:
23+
```bash
24+
openssl genrsa -out key.pem 2048
25+
```
26+
27+
2. Generate a self-signed certificate:
28+
```bash
29+
openssl req -new -x509 -key key.pem -out cert.pem -days 365
30+
```
31+
32+
However, this option has an expiration date and is not signed by a publicly trusted
33+
[certificate authority](https://en.wikipedia.org/wiki/Certificate_authority), which means
34+
you will most likely receive a security warning from your browser while using it.
35+
36+
#### Let's Encrypt
37+
[Let's Encrypt](https://letsencrypt.org/) is a free, automated, and open certificate authority
38+
that provides SSL certificates. You can use tools like Certbot to obtain and install certificates.
39+
To use Let's Encrypt:
40+
41+
1. Install Certbot.
42+
2. Run Certbot to obtain your certificates:
43+
```bash
44+
sudo certbot certonly --standalone -d yourdomain.com
45+
```
46+
47+
This will generate your SSL certificate and key, typically located in
48+
`/etc/letsencrypt/live/yourdomain.com/`.
49+
50+
### Dockerfile setup
51+
52+
To run Memgraph Lab with custom SSL certificates, you need to create a
53+
Dockerfile that specifies how to build the Docker image with your certificates.
54+
55+
You will need to set the `SSL_CERT_PATH` and `SSL_KEY_PATH` environment variables
56+
to override the default `./ssl/` path used by Lab running in the container to
57+
determine the SSL certificate location. After that, you should copy your certificates
58+
(located in the `ssl` folder at the same location as your `Dockerfile`, for example)
59+
into the container at the specified path.
60+
61+
#### Example Dockerfile
62+
```docker
63+
FROM memgraph/lab:latest
64+
65+
# Environment variables
66+
ENV SSL_IS_ENABLED=true
67+
ENV SSL_CERT_PATH=./myssl/cert.pem
68+
ENV SSL_KEY_PATH=./myssl/key.pem
69+
70+
# COPY source_on_your_machine destination_in_container
71+
COPY ssl/ ./myssl/
72+
73+
EXPOSE 3000
74+
```
75+
76+
#### Building and running the Docker container
77+
78+
1. **Create the SSL Directory**: Make sure your SSL certificate and key are placed
79+
in a directory specified as `COPY` source in your Dockerfile.
80+
81+
2. **Build the Docker Image**: Run the following command to build your Docker image:
82+
`docker build -t memgraph-lab-ssl .`
83+
84+
3. **Run the Docker Container**: Start the container using the following command:
85+
`docker run -p 3000:3000 memgraph-lab-ssl`
86+
87+
4. **Access Memgraph Lab**: You can now access Memgraph Lab in your web browser at
88+
`https://localhost:3000`. Ensure to configure your browser to trust the self-signed
89+
certificate if you are using one.

0 commit comments

Comments
 (0)