mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
nginx: configurable listen ip addresses
Based by idea of pikvm/pikvm#189
This commit is contained in:
parent
6dea594380
commit
334b9f7d7b
@ -39,9 +39,9 @@ http {
|
||||
% if https_enabled:
|
||||
|
||||
server {
|
||||
listen ${http_port};
|
||||
listen ${http_ipv4}:${http_port};
|
||||
% if ipv6_enabled:
|
||||
listen [::]:${http_port};
|
||||
listen [${http_ipv6}]:${http_port};
|
||||
% endif
|
||||
include /etc/kvmd/nginx/certbot.ctx-server.conf;
|
||||
location / {
|
||||
@ -54,9 +54,9 @@ http {
|
||||
}
|
||||
|
||||
server {
|
||||
listen ${https_port} ssl;
|
||||
listen ${https_ipv4}:${https_port} ssl;
|
||||
% if ipv6_enabled:
|
||||
listen [::]:${https_port} ssl;
|
||||
listen [${https_ipv6}]:${https_port} ssl;
|
||||
% endif
|
||||
http2 on;
|
||||
include /etc/kvmd/nginx/ssl.conf;
|
||||
@ -67,9 +67,9 @@ http {
|
||||
% else:
|
||||
|
||||
server {
|
||||
listen ${http_port};
|
||||
listen ${http_ipv4}:${http_port};
|
||||
% if ipv6_enabled:
|
||||
listen [::]:${http_port};
|
||||
listen [${http_ipv6}]:${http_port};
|
||||
% endif
|
||||
include /etc/kvmd/nginx/certbot.ctx-server.conf;
|
||||
include /etc/kvmd/nginx/kvmd.ctx-server.conf;
|
||||
|
||||
@ -74,6 +74,7 @@ from ..validators.os import valid_unix_mode
|
||||
from ..validators.os import valid_options
|
||||
from ..validators.os import valid_command
|
||||
|
||||
from ..validators.net import valid_ip
|
||||
from ..validators.net import valid_ip_or_host
|
||||
from ..validators.net import valid_net
|
||||
from ..validators.net import valid_port
|
||||
@ -806,10 +807,14 @@ def _get_config_scheme() -> dict:
|
||||
|
||||
"nginx": {
|
||||
"http": {
|
||||
"ipv4": Option("0.0.0.0", type=functools.partial(valid_ip, v6=False)),
|
||||
"ipv6": Option("::", type=functools.partial(valid_ip, v4=False)),
|
||||
"port": Option(80, type=valid_port),
|
||||
},
|
||||
"https": {
|
||||
"enabled": Option(True, type=valid_bool),
|
||||
"ipv4": Option("0.0.0.0", type=functools.partial(valid_ip, v6=False)),
|
||||
"ipv6": Option("::", type=functools.partial(valid_ip, v4=False)),
|
||||
"port": Option(443, type=valid_port),
|
||||
},
|
||||
},
|
||||
|
||||
@ -50,8 +50,12 @@ def main(argv: (list[str] | None)=None) -> None:
|
||||
template = in_file.read()
|
||||
|
||||
rendered = mako.template.Template(template).render(
|
||||
http_ipv4=config.nginx.http.ipv4,
|
||||
http_ipv6=config.nginx.http.ipv6,
|
||||
http_port=config.nginx.http.port,
|
||||
https_enabled=config.nginx.https.enabled,
|
||||
https_ipv4=config.nginx.https.ipv4,
|
||||
https_ipv6=config.nginx.https.ipv6,
|
||||
https_port=config.nginx.https.port,
|
||||
ipv6_enabled=network.is_ipv6_enabled(),
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user