fluentd icon indicating copy to clipboard operation
fluentd copied to clipboard

Enable CORS on HTTP Input plugin

Open shacharz opened this issue 12 years ago • 8 comments

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?

shacharz avatar Sep 04 '14 15:09 shacharz

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

repeatedly avatar Sep 08 '14 08:09 repeatedly

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?

kiyoto avatar Sep 20 '14 18:09 kiyoto

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.

shacharz avatar Sep 21 '14 07:09 shacharz

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).

kiyoto avatar Sep 22 '14 19:09 kiyoto

@shacharz Could you try https://github.com/fluent/fluentd/pull/473 on your environment?

repeatedly avatar Nov 14 '14 10:11 repeatedly

I close this issue. If you hit the problem, please reopen this issue.

repeatedly avatar Dec 08 '14 09:12 repeatedly

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 avatar Sep 26 '17 06:09 gma-git-admin

@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'.

adonishi avatar Dec 26 '17 08:12 adonishi