Skip to content

Commit 07444e5

Browse files
committed
add tls_config to node_exporter
1 parent 3359e53 commit 07444e5

5 files changed

Lines changed: 87 additions & 2 deletions

File tree

ansible/deploy-testlists.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use_nginx: false
1313
node_exporter_port: 9100
1414
node_exporter_host: "0.0.0.0"
15-
node_exporter_options: "--web.auth.file={{ node_exporter_htpasswd }}"
1615
- role: geerlingguy.docker
1716
docker_users:
1817
- testlists

ansible/roles/prometheus_node_exporter/defaults/main.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,47 @@ node_exporter_bin_path: /usr/local/bin/node_exporter
1313
node_exporter_host: 'localhost'
1414
node_exporter_port: 8100
1515
node_exporter_htpasswd: '/etc/ooni/prometheus_passwd'
16+
node_exporter_web_config: '/etc/ooni/node_exporter_web_config.yml'
1617
node_exporter_options: ''
1718

1819
node_exporter_state: started
1920
node_exporter_enabled: true
2021
node_exporter_restart: on-failure
22+
23+
tls_cert_file: "/var/lib/dehydrated/certs/{{ inventory_hostname }}/fullchain.pem"
24+
tls_key_file: "/var/lib/dehydrated/certs/{{ inventory_hostname }}/privkey.pem"
25+
26+
tls_client_auth_type: "RequireAndVerifyClientCert" # Enforce client authentication.
27+
28+
tls_client_ca_file: "/etc/ssl/certs/scraper_ca.cert" # Path to the CA certificate file for clients.
29+
30+
tls_client_allowed_sans:
31+
- "DNS:monitoringproxy.dev.ooni.io" # Allow this SAN to match.
32+
- "DNS:monitoringproxy.prod.ooni.io" # Allow this SAN to match.
33+
34+
tls_min_version: "TLS12" # Minimum TLS version allowed.
35+
tls_max_version: "TLS13" # Maximum TLS version allowed.
36+
37+
tls_cipher_suites:
38+
- "TLS_AES_128_GCM_SHA256"
39+
- "TLS_AES_256_GCM_SHA384"
40+
- "TLS_CHACHA20_POLY1305" # Modern, secure cipher suites.
41+
42+
tls_prefer_server_cipher_suites: true # Prefer server cipher suites.
43+
44+
tls_curve_preferences:
45+
- "X25519" # Preferred curves for ECDHE.
46+
47+
http2_enabled: true # Enable HTTP/2 support.
48+
49+
# Default HTTP headers
50+
http_csp: "default-src 'self';" # Content-Security-Policy.
51+
http_x_frame_options: "DENY" # X-Frame-Options.
52+
http_x_content_type_options: "nosniff" # X-Content-Type-Options.
53+
http_x_xss_protection: "1; mode=block" # X-XSS-Protection.
54+
http_strict_transport_security: "max-age=63072000; includeSubDomains; preload" # HSTS settings.
55+
56+
basic_auth_users: {} # No basic authentication by default.
57+
58+
rate_limit_interval: "10s" # Time interval between requests.
59+
rate_limit_burst: 20 # Allow a burst of 20 requests.

ansible/roles/prometheus_node_exporter/tasks/install.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@
5151
- monitoring
5252
- node_exporter
5353
- config
54+
when: use_nginx
55+
56+
- name: Copy ooni CA cert for client authentication
57+
copy:
58+
src: scraper_ca.cert
59+
dest: /etc/ssl/certs/scraper_ca.cert
60+
mode: 0644
61+
owner: root
62+
group: root
63+
64+
- name: Copy node_exporter web_config
65+
template:
66+
src: node_exporter_web_config.j2
67+
dest: /etc/ooni/node_exporter_web_config.yml
68+
mode: 0644
5469

5570
- name: Copy the node_exporter systemd unit file.
5671
template:

ansible/roles/prometheus_node_exporter/templates/node_exporter.service.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Description=NodeExporter
44
[Service]
55
TimeoutStartSec=0
66
User=node_exporter
7-
ExecStart={{ node_exporter_bin_path }} --web.listen-address={{ node_exporter_host }}:{{ node_exporter_port }} {{ node_exporter_options }}
7+
ExecStart={{ node_exporter_bin_path }} --web.listen-address={{ node_exporter_host }}:{{ node_exporter_port }} --web.config.file={{node_exporter_web_config }} {{ node_exporter_options }}
88
Restart={{ node_exporter_restart }}
99

1010
[Install]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
tls_server_config:
2+
cert_file: "{{ tls_cert_file }}" # Certificate file for server authentication.
3+
key_file: "{{ tls_key_file }}" # Key file for server authentication.
4+
client_auth_type: "{{ tls_client_auth_type | default('NoClientCert') }}" # Server policy for client authentication.
5+
client_ca_file: "{{ tls_client_ca_file }}" # CA certificate file for client authentication.
6+
client_allowed_sans:
7+
- {{ tls_client_allowed_sans | map('tojson') | join(', ') }} # SAN matches for client certificate.
8+
min_version: "{{ tls_min_version | default('TLS12') }}" # Minimum acceptable TLS version.
9+
max_version: "{{ tls_max_version | default('TLS13') }}" # Maximum acceptable TLS version.
10+
cipher_suites:
11+
- {{ tls_cipher_suites | map('tojson') | join(', ') }} # Supported cipher suites.
12+
prefer_server_cipher_suites: {{ tls_prefer_server_cipher_suites | default(true) }} # Server cipher suite preference.
13+
curve_preferences:
14+
- {{ tls_curve_preferences | map('tojson') | join(', ') }} # Elliptic curves for ECDHE handshake.
15+
16+
http_server_config:
17+
http2: {{ http2_enabled | default(true) }} # Enable HTTP/2 support.
18+
headers:
19+
Content-Security-Policy: "{{ http_csp }}" # Content-Security-Policy for HTTP responses.
20+
X-Frame-Options: "{{ http_x_frame_options }}" # X-Frame-Options for HTTP responses.
21+
X-Content-Type-Options: "{{ http_x_content_type_options }}" # X-Content-Type-Options for responses.
22+
X-XSS-Protection: "{{ http_x_xss_protection }}" # X-XSS-Protection for responses.
23+
Strict-Transport-Security: "{{ http_strict_transport_security }}" # Strict-Transport-Security for responses.
24+
25+
basic_auth_users:
26+
{% for user, pass in basic_auth_users.items() %}
27+
{{ user }}: "{{ pass }}"
28+
{% endfor %}
29+
30+
rate_limit:
31+
interval: "{{ rate_limit_interval }}" # Time interval between requests.
32+
burst: "{{ rate_limit_burst }}" # Permits a burst of requests.

0 commit comments

Comments
 (0)