diff --git a/README.md b/README.md index 1329bec..b9ab39f 100644 --- a/README.md +++ b/README.md @@ -29,5 +29,39 @@ enable log: error_log /usr/local/etc/openresty/logs/error.log; ``` +## MacOS + +Binary: + +```bash +➤ which openresty 20:17:35 +/usr/local/bin/openresty +``` + +Configuration: + +```bash +➤ pwd 20:17:57 +/usr/local/opt/openresty +``` + +```bash +➤ pwd 20:20:00 +/usr/local/opt/openresty/nginx/resty_funcs +``` + +Update: + +```bash +weli@ovpn-12-178:/u/l/o/o/n/resty_funcs +➤ pwd 20:20:38 +/usr/local/opt/openresty/nginx/resty_funcs +weli@ovpn-12-178:/u/l/o/o/n/resty_funcs +➤ cp ~/works/resty_functions/* . 20:20:40 +weli@ovpn-12-178:/u/l/o/o/n/resty_funcs +➤ +``` + + diff --git a/music-room.conf b/music-room.conf index d93c7ea..d598b56 100644 --- a/music-room.conf +++ b/music-room.conf @@ -1,61 +1,47 @@ server { - server_name music-room.alchemy-studio.cn; + set $servername "music-room.alchemy-studio.cn"; +# set $servername "localhost"; + server_name $servername; listen 443 ssl; +# listen 8001; # for testing, same with Vue Vite Port - set $tmp_file_dir "/file_upload"; # 文件存储路径 + # disable in local test env + 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 + + set $tmp_file_dir "/file_upload/"; # 文件存储路径 set $task_server "http://127.0.0.1:8080"; # task server host + set $resty_loc "/usr/local/openresty"; location / { try_files $uri $uri/ /index.html; - proxy_set_header Host music-room.alchemy-studio.cn; + proxy_set_header Host $servername; 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 /usr/local/openresty/nginx/html/music-room; + root $resty_loc/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; + content_by_lua_file $resty_loc/resty_funcs/upload.lua; } #Combine image files location /api/ngx/image/combine { - content_by_lua_file /usr/local/openresty/resty_funcs/combine.lua; + content_by_lua_file $resty_loc/resty_funcs/combine.lua; } #Static file server location /file_upload { default_type ""; - alias /file_upload/; + alias $tmp_file_dir; 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}) - } - } location /api/v1/ws/ { proxy_pass http://127.0.0.1:3001/api/v1/ws/; @@ -69,7 +55,4 @@ server { 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 }