Merge pull request #51 from svc-design/codex/update-openresty-configuration-in-files

feat: configure OpenResty vhosts for multiple domains
This commit is contained in:
shenlan 2025-08-05 17:34:43 +08:00 committed by GitHub
commit d27c73f272
3 changed files with 35 additions and 11 deletions

View File

@ -1,15 +1,33 @@
- hosts: all ---
- name: setup OpenResty server
hosts: icp-aliyun
become: true become: true
vars: vars:
# Use the inventory hostname for delegation so Ansible domain:
# applies the correct connection variables - name: cn-homepage.svc.plus
ops_host: "k8s-1" ssl_certificate: /etc/ssl/svc.plus.pem
masters: ssl_certificate_key: /etc/ssl/svc.plus.rsa.key
- "k8s-1" - name: cn-artifact.svc.plus
nodes: ssl_certificate: /etc/ssl/svc.plus.pem
- "k8s-2" ssl_certificate_key: /etc/ssl/svc.plus.rsa.key
- "k8s-3"
roles: roles:
- roles/vhosts/common/ - roles/vhosts/common/
- roles/vhosts/ssh-trust/ - roles/vhosts/ssh-trust/
- roles/vhosts/OpenResty/ - roles/vhosts/OpenResty/
---
- name: setup OpenResty server
hosts: global-hub
become: true
vars:
domain:
- name: global-homepage.svc.plus
ssl_certificate: /etc/ssl/svc.plus.pem
ssl_certificate_key: /etc/ssl/svc.plus.rsa.key
- name: global-artifact.svc.plus
ssl_certificate: /etc/ssl/svc.plus.pem
ssl_certificate_key: /etc/ssl/svc.plus.rsa.key
roles:
- roles/vhosts/common/
- roles/vhosts/ssh-trust/
- roles/vhosts/OpenResty/

View File

@ -39,7 +39,7 @@
- name: Verify OpenResty core API - name: Verify OpenResty core API
shell: | shell: |
curl -fsS -X POST http://127.0.0.1:8080/api/askai \ curl -fsS -X POST http://127.0.0.1/api/askai \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d '{"question":"你好"}' -d '{"question":"你好"}'
register: openresty_verify register: openresty_verify

View File

@ -4,9 +4,13 @@ events { worker_connections 1024; }
http { http {
lua_shared_dict limit_cache 10m; lua_shared_dict limit_cache 10m;
{% for site in domain %}
server { server {
listen 80; listen 80;
server_name localhost; listen 443 ssl;
server_name {{ site.name }};
ssl_certificate {{ site.ssl_certificate }};
ssl_certificate_key {{ site.ssl_certificate_key }};
location /api/askai { location /api/askai {
access_by_lua_block { access_by_lua_block {
@ -53,4 +57,6 @@ http {
proxy_pass http://127.0.0.1:5000; proxy_pass http://127.0.0.1:5000;
} }
} }
{% endfor %}
} }