# Follow\_redirects not implemented in http output plugin for Logstash

**URL:** <https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824>\
**Category:** Logstash\
**Created:** [April 29, 2016, 4:03pm UTC](https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824 "2016-04-29T16:03:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sergej-Popov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergej-popov/32/9489_2.png) [@Sergej-Popov](https://discuss.elastic.co/u/Sergej-Popov)\
**Post date:** [April 29, 2016, 4:03pm UTC](https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824/1 "2016-04-29T16:03:08Z")

</div>

I am having difficult time making logstash http output plugin to forward events to http endpoint which returns 307. (no control over that). Redirect needs to be followed to get to the right URL.

Docs specify follow\_redirects option:  
[https://www.elastic.co/guide/en/logstash/current/plugins-outputs-http.html#plugins-outputs-http-follow\_redirects](https://www.elastic.co/guide/en/logstash/current/plugins-outputs-http.html#plugins-outputs-http-follow_redirects)

Looking at the source code this seems to be not implemented at all.  
Unless I'm looking in the wrong place:

> <https://github.com/logstash-plugins/logstash-output-http/blob/master/lib/logstash/outputs/http.rb>

Logstash just blows up whenever it sees 307

My logstash config:

```
input {
  beats {
       port => 5656
       host => "127.0.0.1"
  }
}

output {
  http {
	http_method => "post"
	format => "message"
	content_type => "application/json"
	url => "http://127.0.0.1:111/foo/bar"
	message => '%{message}'
	follow_redirects => true
	headers => {
		"foo" => "bar"
	}
  }
}

```

Is there a workaround? Is it planned to be implemented?

Thanks!

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [April 30, 2016, 3:19pm UTC](https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824/2 "2016-04-30T15:19:36Z")

</div>

It _looks_ like the `follow_redirects` option is passed to the HTTP client library, but there could of course be a bug somewhere.

> <https://github.com/logstash-plugins/logstash-mixin-http_client/blob/v2.2.4/lib/logstash/plugin_mixins/http_client.rb#L100-L113>

---

<div class="post-metadata">

**Author:** ![Sergej-Popov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergej-popov/32/9489_2.png) [@Sergej-Popov](https://discuss.elastic.co/u/Sergej-Popov)\
**Post date:** [May 6, 2016, 7:35am UTC](https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824/3 "2016-05-06T07:35:40Z")

</div>

I'm not a ruby dev, so it is hard for me to investigate, but I don't see how this option is passed to http client from Logstash http plugin. It seems only URL, method, body and headers are passed.

Or is it implicitly available via some scope ruby magic?

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [May 8, 2016, 8:39pm UTC](https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824/4 "2016-05-08T20:39:56Z")

</div>

Unless I'm mistaken the class in the file I linked to is basically merged with the http output plugin class so everything in the mixin class is also available in the plugin.

---

<div class="post-metadata">

**Author:** ![Sergej-Popov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergej-popov/32/9489_2.png) [@Sergej-Popov](https://discuss.elastic.co/u/Sergej-Popov)\
**Post date:** [May 9, 2016, 7:43am UTC](https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824/5 "2016-05-09T07:43:46Z")

</div>

Thanks Magnus, will try to debug with http mixin client.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:58am UTC](https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824/6 "2017-07-06T04:58:37Z")

</div>



---

<div class="post-metadata">

**Author:** ![rclarke](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rclarke/32/68604_2.png) [@rclarke](https://discuss.elastic.co/u/rclarke)\
**Post date:** [October 28, 2021, 7:04am UTC](https://discuss.elastic.co/t/follow-redirects-not-implemented-in-http-output-plugin-for-logstash/48824/7 "2021-10-28T07:04:17Z")

</div>

The http library used is very conservative when it comes to status code handling. According to the RFC only `HEAD` and `GET` requests should be automatically redirected. Others like POST need user interaction (e.g. a browser dialog window).

The HTTP client does allow for having a custom redirect strategy to override this behaviour and even provides a more Lax strategy..aptly named [LaxRedirectStrategy](https://hc.apache.org/httpcomponents-client-4.5.x/current/httpclient/apidocs/org/apache/http/impl/client/LaxRedirectStrategy.html). Even this strategy won't redirect PUT requests, only HEAD/GET/DELETE/POST.

So at the moment there is no workaround other than using a `GET` request instead of a POST against the endpoint.
