http - How to send a response with HAProxy without passing the request to web servers -



http - How to send a response with HAProxy without passing the request to web servers -

the server receiving thousands of options requests due cors (cross-origin resource sharing). right now, every options request beingness sent 1 of servers, bit wasteful, knowing haproxy can add together cors headers without help of web server.

frontend https-in ... use_backend cors_headers if meth_options ... backend cors_headers rspadd access-control-allow-origin:\ https://www.example.com rspadd access-control-max-age:\ 31536000

however work need specify @ to the lowest degree 1 live server in cors_headers backend , server still receive requests.

how can handle request in backend without specifying servers? how can stop propagation of request servers, while sending response browser , keeping connection alive?

the way in haproxy 1.5.14 manually triggering 503 error (no servers available handle request) , setting error page file custom cors headers.

backend cors_headers errorfile 503 /path/to/custom/file.http

the file.http should contain desired headers , 2 empty lines @ end

http/1.1 200 ok access-control-allow-origin: https://www.example.com access-control-max-age: 31536000 content-length: 0 cache-control: private <remove line completely>

this "method" has couple of limitations:

there no way check origin before sending cors headers, either have have static list of allowed origins or have allow origins

lack of dynamic headers: can't do

http-response set-header date %[date(),http_date]

or set expires header.

note: if updating http file dynamically on time, apply changes haproxy have restart it. can graceful restart or hard restart, in either case new file loaded, cached , served immediately.

http cors haproxy

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -