Против ниже конфиг nginx:
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?