split nginx config by domain

This commit is contained in:
moicen
2022-02-01 22:27:42 +08:00
committed by 木逸辰
parent af7b91674e
commit a1a3c17a21
9 changed files with 322 additions and 13 deletions
+44
View File
@@ -0,0 +1,44 @@
server {
# https://serverfault.com/questions/798734/use-variable-for-server-name-in-nginx#
# server_name $servername;
server_name "music-room.alchemy-studio.cn";
listen 443 ssl;
client_max_body_size 10M;
set $resty_loc "/usr/local/openresty";
# disable in local test env
ssl_certificate /etc/letsencrypt/live/alchemy-studio.cn/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/alchemy-studio.cn/privkey.pem; # managed by Certbot
location / {
try_files $uri $uri/ /index.html;
proxy_set_header Host "music-room.alchemy-studio.cn";
proxy_set_header X-Real-IP $remote_addr;
# disable in local test env
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $remote_addr;
}
root $resty_loc/nginx/html/alchemy/music-room;
index index.html;
# 公众号校验
location /MP_verify_Jo6pKmy43wx7S5Sh.txt {
return 200 'Jo6pKmy43wx7S5Sh';
}
# 小程序业务域名校验
location /Q25f8xC3Jo.txt {
return 200 '323072b225a694281cd23496fa6737ef';
}
}
server {
listen 80;
server_name "music-room.alchemy-studio.cn";
location / {
return 301 https://$host$request_uri;
}
}