Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions configs/nginx/nginx.conf.mako
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ http {
include /etc/kvmd/nginx/ssl.conf;
include /etc/kvmd/nginx/kvmd.ctx-server.conf;
include /usr/share/kvmd/extras/*/nginx.ctx-server.conf;

% if prometheus_use_separate_port:
location /api/export/prometheus/metrics {
return 404;
}
% endif
}

% else:
Expand All @@ -74,7 +80,30 @@ http {
include /etc/kvmd/nginx/certbot.ctx-server.conf;
include /etc/kvmd/nginx/kvmd.ctx-server.conf;
include /usr/share/kvmd/extras/*/nginx.ctx-server.conf;

% if prometheus_use_separate_port:
location /api/export/prometheus/metrics {
return 404;
}
% endif
}

% endif

% if prometheus_use_separate_port:
server {
listen ${prometheus_http_port};
% if ipv6_enabled:
listen [::]:${prometheus_http_port};
% endif

location /api/export/prometheus/metrics {
rewrite ^/api$ / break;
rewrite ^/api/(.*)$ /$1 break;
proxy_pass http://kvmd;
include /etc/kvmd/nginx/loc-proxy.conf;
auth_request off;
}
}
% endif
}
4 changes: 4 additions & 0 deletions kvmd/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ def _get_config_scheme() -> dict:
"enabled": Option(True, type=valid_bool),
"port": Option(443, type=valid_port),
},
"prometheus": {
"use_separate_port": Option(False, type=valid_bool),
"http_port": Option(22091, type=valid_port),
},
},

"janus": {
Expand Down
2 changes: 2 additions & 0 deletions kvmd/apps/ngxmkconf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def main(argv: (list[str] | None)=None) -> None:
https_enabled=config.nginx.https.enabled,
https_port=config.nginx.https.port,
ipv6_enabled=network.is_ipv6_enabled(),
prometheus_use_separate_port=config.nginx.prometheus.use_separate_port,
prometheus_http_port=config.nginx.prometheus.http_port,
)

if options.print:
Expand Down