server { # https://serverfault.com/questions/798734/use-variable-for-server-name-in-nginx# # server_name $servername; server_name "ts.localhost"; listen 8088; client_max_body_size 10M; set $task_server "http://127.0.0.1:8080"; # Java task_server set $huiwing_htyts_rust "127.0.0.1:3003"; # huiwing 仓库 htyts(Rust) set $task_server_rust "http://$huiwing_htyts_rust"; set $htyuc "http://127.0.0.1:3000"; #htyuc host set $resty_loc "/usr/local/opt/openresty"; location /api/v1/ts/ { add_header Access-Control-Allow-Origin $http_origin always; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always; add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always; add_header Access-Control-Allow-Credentials true always; add_header Access-Control-Max-Age 86400 always; if ($request_method = 'OPTIONS') { return 200; } proxy_pass http://127.0.0.1:8080/api/v1/ts/; } location /api/v2/ts/ { add_header Access-Control-Allow-Origin $http_origin always; add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS' always; add_header Access-Control-Allow-Headers 'Authorization,HtyAdminToken,HtySudoerToken,HtyHost,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type' always; add_header Access-Control-Allow-Credentials true always; add_header Access-Control-Max-Age 86400 always; if ($request_method = 'OPTIONS') { return 200; } proxy_pass http://$huiwing_htyts_rust/api/v1/ts/; } }