我想使用 SSL 证书保护 docker prometheus 容器。问题是 prometheus 容器没有 nginx 或 apache2 webserver 来将证书放入其配置文件夹中。所以我该怎么办?任何建议都将不胜感激。
答案1
创建一个 web.yml 文件并添加此配置
tls_server_config:
cert_file: /etc/prometheus/prometheus.crt # place of the cert file inside the docker container
key_file: /etc/prometheus/prometheus.key # place of the key file inside the docker container
在 prometheus.yml 文件中添加此部分
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['example.com:443'] # Replace with your SSL-enabled endpoint
scheme: https # Use HTTPS
tls_config:
cert_file: '/etc/prometheus/prometheus.crt' # Path to your SSL certificate file
key_file: '/etc/prometheus/prometheus.key' # Path to your private key file
然后按如下方式运行 prometheus docker 容器
docker run -d \
--name prometheus \
-p 9090:9090 \
prom/prometheus \
--config.file=/etc/prometheus/prometheus.yml \
--web.config.file=/etc/prometheus/web.yml
根据您的环境更改文件的路径。