2021-09-04 12:38:15 +08:00
|
|
|
server {
|
2021-11-28 09:59:30 +08:00
|
|
|
# https://serverfault.com/questions/798734/use-variable-for-server-name-in-nginx#
|
|
|
|
|
# server_name $servername;
|
2022-01-15 21:23:13 +08:00
|
|
|
server_name "admin.moicen.com";
|
2021-09-04 12:38:15 +08:00
|
|
|
listen 443 ssl;
|
2021-12-30 23:11:12 +08:00
|
|
|
client_max_body_size 10M;
|
2021-09-04 12:38:15 +08:00
|
|
|
|
2021-11-18 20:45:55 +08:00
|
|
|
# disable in local test env
|
2022-01-15 21:23:13 +08:00
|
|
|
ssl_certificate /etc/letsencrypt/live/admin.moicen.com/fullchain.pem; # managed by Certbot
|
|
|
|
|
ssl_certificate_key /etc/letsencrypt/live/admin.moicen.com/privkey.pem; # managed by Certbot
|
2021-11-18 20:45:55 +08:00
|
|
|
|
|
|
|
|
set $tmp_file_dir "/file_upload/"; # 文件存储路径
|
2021-11-28 16:29:59 +08:00
|
|
|
set $task_server "http://127.0.0.1:8080"; # task server host
|
|
|
|
|
set $htyuc "http://127.0.0.1:3000"; #htyuc host
|
2021-11-18 20:45:55 +08:00
|
|
|
set $resty_loc "/usr/local/openresty";
|
2021-11-28 09:30:52 +08:00
|
|
|
set $convert "/usr/bin/convert";
|
2021-09-04 12:38:15 +08:00
|
|
|
|
|
|
|
|
location / {
|
|
|
|
|
try_files $uri $uri/ /index.html;
|
2022-01-15 21:23:13 +08:00
|
|
|
proxy_set_header Host "admin.moicen.com";
|
2021-09-04 12:38:15 +08:00
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
2021-11-18 20:45:55 +08:00
|
|
|
# disable in local test env
|
2021-09-04 12:38:15 +08:00
|
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-Host $remote_addr;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-15 21:23:13 +08:00
|
|
|
root $resty_loc/nginx/html/admin;
|
2021-09-04 12:38:15 +08:00
|
|
|
index index.html;
|
|
|
|
|
|
2022-01-20 20:48:00 +08:00
|
|
|
if ($http_origin !~ [a-z]+\.moicen\.com$) {
|
|
|
|
|
return 403;
|
|
|
|
|
}
|
|
|
|
|
add_header Access-Control-Allow-Origin $http_origin;
|
|
|
|
|
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
|
|
|
|
|
add_header Access-Control-Allow-Headers 'Authorization,unionid,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
|
|
|
|
|
add_header Access-Control-Allow-Credentials true;
|
|
|
|
|
add_header Access-Control-Max-Age 86400;
|
|
|
|
|
if ($request_method = 'OPTIONS') {
|
|
|
|
|
return 200;
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-04 12:38:15 +08:00
|
|
|
#Upload image files
|
|
|
|
|
location /api/ngx/image/upload {
|
2021-11-18 20:45:55 +08:00
|
|
|
content_by_lua_file $resty_loc/resty_funcs/upload.lua;
|
2021-09-04 12:38:15 +08:00
|
|
|
}
|
|
|
|
|
#Combine image files
|
|
|
|
|
location /api/ngx/image/combine {
|
2021-11-18 20:45:55 +08:00
|
|
|
content_by_lua_file $resty_loc/resty_funcs/combine.lua;
|
2021-09-04 12:38:15 +08:00
|
|
|
}
|
2021-12-30 22:04:57 +08:00
|
|
|
#Audio file download
|
2021-12-30 22:22:15 +08:00
|
|
|
location /api/ngx/audio/upload {
|
|
|
|
|
content_by_lua_file $resty_loc/resty_funcs/upload_audio.lua;
|
2021-12-30 22:04:57 +08:00
|
|
|
}
|
2021-12-28 11:26:26 +08:00
|
|
|
#Audio file convert
|
|
|
|
|
location /api/ngx/audio/convert {
|
2022-01-04 22:17:55 +08:00
|
|
|
content_by_lua_file $resty_loc/resty_funcs/convert_audio.lua;
|
2021-12-28 11:26:26 +08:00
|
|
|
}
|
2021-09-04 12:38:15 +08:00
|
|
|
|
|
|
|
|
location /api/v1/ws/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:3001/api/v1/ws/;
|
|
|
|
|
}
|
|
|
|
|
location /api/v1/uc/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:3000/api/v1/uc/;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-28 10:09:52 +08:00
|
|
|
|
|
|
|
|
server {
|
|
|
|
|
listen 80;
|
2022-01-15 21:23:13 +08:00
|
|
|
server_name "admin.moicen.com";
|
2021-11-28 10:09:52 +08:00
|
|
|
location / {
|
|
|
|
|
return 301 https://$host$request_uri;
|
|
|
|
|
}
|
|
|
|
|
}
|