Enable CORS on HTTP Input plugin
Is it possible to enable cross origin resource sharing with the http input plugin, so a browser can report directly to a server different from the server hosting the web page?
Do you want to expose Fluentd's in_http for the internet? I'm not sure the current status but fluent-plugin-http-enhanced seems to have such feature.
https://github.com/parolkar/fluent-plugin-http-enhanced
Another thought: might be helpful to create a how-to guide on using Fluentd in_http behind a proxy server (ex: nginx).
@shacharz What's the use case that you have in mind?
browsers sending http post directly to the flutend server.
On Sat, Sep 20, 2014 at 9:09 PM, Kiyoto [email protected] wrote:
Another thought: might be helpful to create a how-to guide on using Fluentd in_http behind a proxy server (ex: nginx).
@shacharz https://github.com/shacharz What's the use case that you have in mind?
— Reply to this email directly or view it on GitHub https://github.com/fluent/fluentd/issues/426#issuecomment-56275549.
Hm. I am not entirely averse to implementing CORS (for example, if Fluentd is deployed on Heroku, this can come in handy). Also, I am not sure how actively https://github.com/parolkar/fluent-plugin-http-enhanced is maintained (the last update was two years ago).
@shacharz Could you try https://github.com/fluent/fluentd/pull/473 on your environment?
I close this issue. If you hit the problem, please reopen this issue.
Am using in_http to take in the json log data from my angular app. Have added the angular app url in the list for cors_allow_origins in the conf file. The source configuration is reproduced here for reference:
<source>
@type http
port 8282
bind 0.0.0.0
body_size_limit 32m
keepalive_timeout 10s
add_remote_addr true
##add_http_headers true
cors_allow_origins ["http://dev.myapp.com"]
format json
</source>
But, I still get the HTTP 400 bad request error as given below:
XMLHttpRequest cannot load http://dev.myapp:8282/app.RouteChange. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://dev.myapp.com' is therefore not allowed access. The response had HTTP status code 400.
Am I missing some important configuration or doing something wrong here?
@gma-git-admin I came across the same problem, and find out http-input plugin only support preflight less CORS.
var xhr = new XMLHttpRequest();
xhr.open('POST', url);
// xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(json);
code above works fine with http-input plugin, since browser do not send preflight request. but uncomment 'Content-Type' line will fail, because browser will send preflight request before actual json POST request. and preflight request always fail with '400 bad request'.