我有以下 nginx.conf 文件:
server {
listen 8080;
server_name dummy_server;
root /usr/share/nginx/html;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'Authorization,DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain; charset=utf-8';
add_header 'Content-Length' 0;
return 204;
}
default_type 'application/json';
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS' always;
add_header 'Content-Type' 'application/json';
if ($request_uri ~* "([^/]*$)" ) {
set $last_path_component $1;
}
try_files $last_path_component.json $last_path_component.json =404;
}
}
Run Code Online (Sandbox Code Playgroud)
我想healthcheck.json
在localhost:8080/v1/healthcheck
被要求时提供服务。但是,如果我没有明确点击 ,nginx …