|
| 1 | +--- |
| 2 | +title: "RustFS TLS Configuration Guide" |
| 3 | +description: "Configure TLS for RustFS instances to access RustFS via HTTPS, ensuring secure file storage and access." |
| 4 | +--- |
| 5 | + |
| 6 | +# RustFS TLS Configuration |
| 7 | + |
| 8 | +RustFS supports [configuring TLS](../../installation/security-checklists.md#2-network-transport-encryption-tlsssl) to enable more secure access and usage of RustFS instances. You need to specify the certificate path required for TLS using the environment variable `RUSTFS_TLS_PATH`. |
| 9 | + |
| 10 | +## Configuration |
| 11 | + |
| 12 | +### Prerequisites |
| 13 | + |
| 14 | +- A working RustFS instance (see the [installation guide](../../en/installation/index.md) for details) |
| 15 | +- An available certificate pair (including the certificate file and the private key file) |
| 16 | + |
| 17 | +**Note**: The certificate pair must be named `rustfs_cert.pem` and `rustfs_key.pem`, and placed in the specified certificate path. |
| 18 | + |
| 19 | +### Configuration Steps |
| 20 | + |
| 21 | +* Linux Installation |
| 22 | + |
| 23 | +1. Edit the RustFS instance configuration file (the default file is `/etc/default/rustfs`) and add the `RUSTFS_TLS_PATH` environment variable. |
| 24 | + |
| 25 | + ```bash |
| 26 | + # Edit the RustFS instance configuration file |
| 27 | + sudo vi /etc/default/rustfs |
| 28 | + |
| 29 | + # Add the RUSTFS_TLS_PATH environment variable |
| 30 | + RUSTFS_TLS_PATH="/opt/tls" |
| 31 | + ``` |
| 32 | + |
| 33 | +**Note**: You can specify any path for `RUSTFS_TLS_PATH`, but it must contain both `rustfs_cert.pem` and `rustfs_key.pem`. |
| 34 | + |
| 35 | +2. Restart the RustFS instance to apply the configuration. |
| 36 | + |
| 37 | + ```bash |
| 38 | + systemctl restart rustfs |
| 39 | + ``` |
| 40 | + |
| 41 | +Access the instance via `https://rustfs.example.com:9000`. |
| 42 | + |
| 43 | + |
| 44 | +* Docker Installation |
| 45 | + |
| 46 | +1. Mount the certificate path using the `-v` parameter and specify the `RUSTFS_TLS_PATH` environment variable using the `-e` parameter. |
| 47 | + |
| 48 | + ```bash |
| 49 | + docker pull rustfs/rustfs:latest |
| 50 | + docker run -d \ |
| 51 | + --name rustfs \ |
| 52 | + -e RUSTFS_TLS_PATH="/opt/tls/" |
| 53 | + -v /opt/tls:/opt/tls \ |
| 54 | + -p 9000:9000 \ |
| 55 | + -v /data:/data \ |
| 56 | + rustfs/rustfs:latest |
| 57 | + ``` |
| 58 | + |
| 59 | +2. Restart the RustFS instance container, then access the instance via `https://rustfs.example.com:9000`. |
| 60 | + |
| 61 | +**Note**: Since the RustFS instance container runs as the `rustfs` user by default, make sure the certificate files (`rustfs_key.pem` and `rustfs_cert.pem`) are owned by `rustfs`. Otherwise, the RustFS instance will fail to read the certificate files due to permission issues, causing the TLS configuration to fail. |
0 commit comments