2021-09-04 12:38:15 +08:00
|
|
|
server {
|
|
|
|
|
server_name music-room.alchemy-studio.cn;
|
|
|
|
|
listen 443 ssl;
|
|
|
|
|
|
2021-09-06 18:56:59 +08:00
|
|
|
set $tmp_file_dir "/file_upload"; # 文件存储路径
|
2021-09-04 12:38:15 +08:00
|
|
|
set $task_server "http://127.0.0.1:8080"; # task server host
|
|
|
|
|
|
|
|
|
|
location / {
|
|
|
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
|
proxy_set_header Host music-room.alchemy-studio.cn;
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
|
|
|
proxy_set_header X-Forwarded-For $remote_addr;
|
|
|
|
|
proxy_set_header X-Forwarded-Host $remote_addr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
root /usr/local/openresty/nginx/html/music-room;
|
|
|
|
|
index index.html;
|
|
|
|
|
|
|
|
|
|
location /api/ngx/test/hello_world {
|
|
|
|
|
#设置content type
|
|
|
|
|
default_type text/html ;
|
|
|
|
|
# HTTP Status Code 和 内容
|
|
|
|
|
return 200 "hello world! ";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#Upload image files
|
|
|
|
|
location /api/ngx/image/upload {
|
|
|
|
|
content_by_lua_file /usr/local/openresty/resty_funcs/upload.lua;
|
|
|
|
|
}
|
|
|
|
|
#Combine image files
|
|
|
|
|
location /api/ngx/image/combine {
|
|
|
|
|
content_by_lua_file /usr/local/openresty/resty_funcs/combine.lua;
|
|
|
|
|
}
|
2021-09-06 19:33:30 +08:00
|
|
|
#Static file server
|
|
|
|
|
location /file_upload {
|
|
|
|
|
default_type "";
|
|
|
|
|
alias /file_upload/;
|
|
|
|
|
autoindex on;
|
|
|
|
|
autoindex_exact_size off;
|
|
|
|
|
autoindex_localtime on;
|
|
|
|
|
}
|
|
|
|
|
#Download image files
|
|
|
|
|
location /download_image {
|
|
|
|
|
rewrite_by_lua_block{
|
|
|
|
|
-- Get download image id
|
|
|
|
|
local download_image_id = string.match(ngx.var.request_uri, ".*/(.*)$")
|
|
|
|
|
ngx.log(ngx.INFO , "Download image id: " .. download_image_id)
|
|
|
|
|
|
|
|
|
|
-- Set redirect uri
|
|
|
|
|
--local uri = "/internal_file_upload/" .. download_image_id .. ".jpg"
|
|
|
|
|
--return ngx.exec(uri)
|
|
|
|
|
|
|
|
|
|
local uri = "/file_upload/" .. download_image_id .. ".jpg"
|
|
|
|
|
return ngx.exec(uri, {a = download_image_id})
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-04 12:38:15 +08:00
|
|
|
|
|
|
|
|
location /api/v1/ws/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:3001/api/v1/ws/;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
}
|
|
|
|
|
location /api/v1/uc/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:3000/api/v1/uc/;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
}
|
|
|
|
|
location /api/v1/ts/ {
|
|
|
|
|
proxy_pass http://127.0.0.1:8080/api/v1/ts/;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ssl_certificate /etc/letsencrypt/live/music-room.alchemy-studio.cn/fullchain.pem; # managed by Certbot
|
|
|
|
|
ssl_certificate_key /etc/letsencrypt/live/music-room.alchemy-studio.cn/privkey.pem; # managed by Certbot
|
|
|
|
|
}
|