# Modifying location block for specific paths

**URL:** https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544
**Category:** Questions
**Created:** [June 17, 2020, 9:35pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544 "2020-06-17T21:35:19Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![gmr](https://avatars.discourse-cdn.com/v4/letter/g/49beb7/32.png) [@gmr](https://discuss.konghq.com/u/gmr)
#### Post date: [June 17, 2020, 9:35pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/1 "2020-06-17T21:35:19Z")

</div>

Hi,

I am looking to disable “proxy\_buffering”, but only for certain paths like “/example”. What’s the path of least resistance for achieving this in Kong? I would like to avoid using a custom NGINX template if possible. I tried using KONG\_NGINX\_HTTP\_INCLUDE, but it seems like that does not allow modifying the Kong proxy server block. Using “nginx\_proxy\_” seems promising, but it does not seem possible to add new location blocks.

---

<div class="post-metadata">

### Author: ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)
#### Post date: [June 23, 2020, 6:46pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/2 "2020-06-23T18:46:42Z")

</div>

> [@gmr](#):
>
> proxy\_buffering

What do you mean by buffering here? could you elaborate?  
Kong (by default) doesn’t do anything additional that Nginx for request/response bodies.

---

<div class="post-metadata">

### Author: ![gmr](https://avatars.discourse-cdn.com/v4/letter/g/49beb7/32.png) [@gmr](https://discuss.konghq.com/u/gmr)
#### Post date: [June 23, 2020, 8:58pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/3 "2020-06-23T20:58:24Z")

</div>

Sorry for the confusion, I am referring to this property [http://nginx.org/en/docs/http/ngx\_http\_proxy\_module.html#proxy\_buffering](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering) (i.e. proxy\_buffering off;) .

I mainly want to know if it’s possible to modify the Kong Nginx server block to change that property without using a custom Nginx template.

---

<div class="post-metadata">

### Author: ![hbagdi](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/hbagdi/32/562_2.png) [@hbagdi](https://discuss.konghq.com/u/hbagdi)
#### Post date: [June 24, 2020, 8:46pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/4 "2020-06-24T20:46:53Z")

</div>

You can’t enable or disable this for select paths. You can try to globally enable it using `nginx_proxy_` but I’m not sure what the effects on Kong would be.  
@bungle or @datong.sun could elaborate more on this.

---

<div class="post-metadata">

### Author: ![bungle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/bungle/32/13_2.png) [@bungle](https://discuss.konghq.com/u/bungle)
#### Post date: [July 1, 2020, 6:46pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/5 "2020-07-01T18:46:57Z")

</div>

> [@gmr](#):
>
> for certain paths like “/example”. What’s the path of least resistance for achieving this in Kong? I would like to avoid using a custom NGINX template if possible. I tried using KONG\_NGINX\_HTTP\_INCLUDE, but it seems like that does not allow modifying the Kong proxy server block. Using “nginx\_proxy\_” seems promising, but it does not seem possible to

You can’t on Kong, but you can on `upstream` by adding response header:

> **[X-Accel | NGINX](https://www.nginx.com/resources/wiki/start/topics/examples/x-accel/#x-accel-buffering)**
>
> How to use X-Accel in your NGINX configuration.

To make it dynamic on request time, I already proposed this:

> <https://github.com/Kong/kong/pull/6057>
>
> \### Summary
> 
> \#### Request Buffering
> 
> By default Kong does buffer the request…. This is not ideal when proxying bigger payloads with HTTP 1.1 chunked encoding.
> 
> This PR adds a new property to route entity:
> \`\`\`
> request\_buffering = \<true/false\>
> \`\`\`
> 
> By default that is \`true\` (which is the same as before). Users can now turn the request buffering \`off\` by route-by-route manner by setting \`route.request\_buffering=false\`.
> 
> \#### Response Buffering
> 
> By default Kong does buffer the response. This is not ideal when upstream is sending payloads with HTTP 1.1 chunked encoding.
> 
> This PR adds a new property to route entity:
> \`\`\`
> response\_buffering = \<true/false\>
> \`\`\`
> 
> By default that is \`true\` (which is the same as before). Users can now turn off the response buffering on route-by-route manner by setting \`route.response\_buffering=false\`.

We could make similar modification to add also `service. response_buffering` property to make it dynamic on Kong itself.

---

<div class="post-metadata">

### Author: ![bungle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/bungle/32/13_2.png) [@bungle](https://discuss.konghq.com/u/bungle)
#### Post date: [July 1, 2020, 7:05pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/6 "2020-07-01T19:05:19Z")

</div>

You can also inject new `location` blocks:  
KONG\_NGINX\_PROXY\_INCLUDE=my-locations.conf

---

<div class="post-metadata">

### Author: ![gmr](https://avatars.discourse-cdn.com/v4/letter/g/49beb7/32.png) [@gmr](https://discuss.konghq.com/u/gmr)
#### Post date: [July 1, 2020, 7:19pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/7 "2020-07-01T19:19:16Z")

</div>

`service.response_buffering` would be perfect. We’re currently using the X-Accel-Buffering response header and that’s working great, but we want to try to keep this logic in Kong.

---

<div class="post-metadata">

### Author: ![bungle](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/bungle/32/13_2.png) [@bungle](https://discuss.konghq.com/u/bungle)
#### Post date: [July 1, 2020, 8:05pm UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/8 "2020-07-01T20:05:38Z")

</div>

@gmr, ok cool, I updated the proposal here to also have `service.response_buffering`:

> <https://github.com/Kong/kong/pull/6057>

Any feedback welcomed!

---

<div class="post-metadata">

### Author: ![Kristoffer\_Johansson](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/kristoffer_johansson/32/2116_2.png) [@Kristoffer\_Johansson](https://discuss.konghq.com/u/Kristoffer_Johansson)
#### Post date: [July 31, 2020, 9:29am UTC](https://discuss.konghq.com/t/modifying-location-block-for-specific-paths/6544/9 "2020-07-31T09:29:58Z")

</div>

Would be great to if this is implemented, since there are services in my case which receives large files 5GB\>20GB. Would be great if one had the option to disable it on service level instead of disabling it via globally in Nginx.
