Merge pull request #63 from svc-design/codex/add-default-variable-values-for-vhosts

feat: add vhost defaults and autoindex
This commit is contained in:
shenlan 2025-08-19 14:01:40 +08:00 committed by GitHub
commit db629bc87d
3 changed files with 26 additions and 1 deletions

View File

@ -38,6 +38,9 @@
- global-artifact.svc.plus
ssl_certificate: /etc/ssl/svc.plus.pem
ssl_certificate_key: /etc/ssl/svc.plus.rsa.key
root: /data/update-server
autoindex_paths:
- "/"
type: artifact
roles:
- roles/vhosts/common/

View File

@ -7,14 +7,31 @@ server {
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
root /data/update-server;
root {{ item.root | default(vhost_defaults.root) }};
index index.html;
{% set autoindex_paths = item.autoindex_paths | default(vhost_defaults.autoindex_paths) %}
location / {
{% if '/' in autoindex_paths %}
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
{% endif %}
add_header Accept-Ranges bytes;
try_files $uri $uri/ =404;
}
{% for path in autoindex_paths %}
{% if path != '/' %}
location {{ path }} {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
}
{% endif %}
{% endfor %}
location ~* \.(dmg|zip|tar\.gz|deb|rpm|exe|pkg|AppImage|apk|ipa)$ {
expires 7d;
access_log off;

View File

@ -36,3 +36,8 @@ journald_log_rotation: # 启用 journald 日志管理
# selinux_enable: false
# ssh_auth:
# key: /root/.ssh/id_rsa.pub
vhosts: []
vhost_defaults:
root: /data/update-server
autoindex_paths: []