Merge pull request #54 from svc-design/codex/fix-error-in-main.yml

Handle missing template attr for OpenResty vhosts
This commit is contained in:
shenlan 2025-08-18 11:27:30 +08:00 committed by GitHub
commit 77e0d7bc6b
3 changed files with 42 additions and 38 deletions

View File

@ -38,7 +38,8 @@
- name: Deploy vhost configurations
template:
src: "{{ item.template }}"
# Use item.template if provided; otherwise default to the unified site template
src: "{{ item.template | default('site.conf.j2') }}"
dest: "/usr/local/openresty/nginx/conf/sites-available/{{ item.name }}.conf"
loop: "{{ domain | default([]) }}"
notify: Restart OpenResty

View File

@ -1,35 +0,0 @@
{% set name = 'artifact.svc.plus' if 'artifact' in item.name else item.name %}
# {{ name }} 文件下载服务
server {
listen 443 ssl http2;
server_name {{ name }};
ssl_certificate {{ item.ssl_certificate }};
ssl_certificate_key {{ item.ssl_certificate_key }};
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
root /data/update-server;
index index.html;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location / {
add_header Accept-Ranges bytes;
try_files $uri $uri/ =404;
}
location ~* \.(dmg|zip|tar\.gz|deb|rpm|exe|pkg|AppImage|apk|ipa)$ {
expires 7d;
access_log off;
add_header Cache-Control "public";
add_header Accept-Ranges bytes;
try_files $uri =404;
}
location ~ /\. {
deny all;
}
}

View File

@ -1,3 +1,40 @@
{% if 'artifact' in item.name %}
{% set name = 'artifact.svc.plus' if 'artifact' in item.name else item.name %}
# {{ name }} 文件下载服务
server {
listen 443 ssl http2;
server_name {{ name }};
ssl_certificate {{ item.ssl_certificate }};
ssl_certificate_key {{ item.ssl_certificate_key }};
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
root /data/update-server;
index index.html;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
location / {
add_header Accept-Ranges bytes;
try_files $uri $uri/ =404;
}
location ~* \.(dmg|zip|tar\.gz|deb|rpm|exe|pkg|AppImage|apk|ipa)$ {
expires 7d;
access_log off;
add_header Cache-Control "public";
add_header Accept-Ranges bytes;
try_files $uri =404;
}
location ~ /\\. {
deny all;
}
}
{% else %}
{% set name = item.name %}
lua_package_path "/usr/local/openresty/lualib/?.lua;;";
@ -73,14 +110,15 @@ server {
}
# 静态资源缓存
location ~* \.(?:ico|css|js|gif|jpe?g|png|woff2?)$ {
location ~* \\.(?:ico|css|js|gif|jpe?g|png|woff2?)$ {
expires 30d;
access_log off;
add_header Cache-Control "public";
}
# 隐藏 . 文件
location ~ /\. {
location ~ /\\. {
deny all;
}
}
{% endif %}