Với cấu hình này:Tại sao tôi không thể đặt proxy_set_header trong mệnh đề if?
server {
listen 8080;
location/{
if ($http_cookie ~* "mycookie") {
proxy_set_header X-Request $request;
proxy_pass http://localhost:8081;
}
}
}
Tôi có lỗi này khi tôi tải lại dịch vụ nginx:
Reloading nginx configuration: nginx: [emerg] "proxy_set_header" directive is not allowed here in /etc/nginx/conf.d/check_cookie.conf:5
nginx: configuration file /etc/nginx/nginx.conf test failed
Cấu hình này hoạt động OK, nhưng nó không làm những gì tôi muốn:
server {
listen 8080;
location/{
proxy_set_header X-Request $request;
if ($http_cookie ~* "mycookie") {
proxy_pass http://localhost:8081;
}
}
}
Tại sao tôi không thể đặt chỉ thị proxy_set_header bên trong mệnh đề if?
Cảm ơn trước!
Vui lòng không đăng chéo. http://serverfault.com/questions/506972/nginx-why-i-cant-put-proxy-set-header-inside-an-if-clause – ceejayoz
Tôi đã mở một cuộc trò chuyện để thảo luận về điều này. Chúng ta có thể tiếp tục thảo luận ở đó. http://chat.stackexchange.com/rooms/8745/nginx – Neuquino