निगनेक्स कॉन्फिगरेशन के नीचे:
upstream search {
least_conn;
server www.google.com:80
max_fails=1
fail_timeout=10
weight=1;
keepalive 12;
}
limit_req_zone $binary_remote_addr zone=search:1m rate=10r/s;
resolver 127.0.0.1;
server {
listen 80 default_server;
charset utf-8;
server_name _;
access_log /dev/stdout json;
location @search {
# Deny requests that do not match allowed methods REGEX
if ($request_method !~ ^GET$ ) {
return 405;
}
set $proxy_uri $uri;
if ($proxy_uri ~ ^/[^/]+(/.*)$ ) {
set $proxy_uri "$1";
}
# Deny requests that do not match allowed paths REGEX
if ($proxy_uri !~ ^.*(\?|$) ) {
return 403;
}
# Rate Limit Requests
limit_req zone=search burst=10 nodelay;
# Adding new client_max_body_size service attribute per location
client_max_body_size 1m;
proxy_http_version 1.1;
# Set CORS Headers
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
proxy_set_header Origin "";
proxy_set_header Connection "";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://search$proxy_uri$is_args$args;
}
location /search/ {
client_max_body_size 1m;
# send request to the named location for the service
error_page 418 = @search; return 418;
}
# Default location for unmatched requests
location / {
return 404;
}
location = /health {
return 200;
}
}
चल रहा है
curl -siL -H 'Host: www.google.com' '127.0.0.1/search/'
एक 200 लौटाता है
परंतु
curl -siL -H 'Host: www.google.com' '127.0.0.1/search'
404 देता है।
मैं स्लैश रिटर्न 200 के साथ और उसके साथ कैसे बनाऊं?
location /search/
है location /search
। अन्यथा, आप इस StackOverflow प्रश्न को रेगेक्स के साथ अनुगामी स्लैश जोड़ने के बारे में देखना चाह सकते हैं ।