# Discourse socketed: outer nginx rate limiting when opening emoticons

**URL:** https://meta.discourse.org/t/discourse-socketed-outer-nginx-rate-limiting-when-opening-emoticons/96417
**Category:** Self-hosting
**Created:** [September 5, 2018, 3:15pm UTC](https://meta.discourse.org/t/discourse-socketed-outer-nginx-rate-limiting-when-opening-emoticons/96417 "2018-09-05T15:15:17Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![TheBestPessimist](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/thebestpessimist/32/247704_2.png) [@TheBestPessimist](https://meta.discourse.org/u/TheBestPessimist)
#### Post date: [September 7, 2018, 6:57am UTC](https://meta.discourse.org/t/discourse-socketed-outer-nginx-rate-limiting-when-opening-emoticons/96417/3 "2018-09-07T06:57:59Z")

</div>

HA! ([_again_](https://meta.discourse.org/t/nginx-in-front-of-discourse-no-ip-adresses/96382/5))

I found a way to disable the rate limiting only for my discourse server:

```plaintext
#=================================================
# Rate limit EVERYTHING!!!!!!! (:blush: except for discourse)

map $http_host $rate_limit_except_discourse {
    "chat.tbp.land" ""; # in case of an empty string, limit_req_zone won't be applied!
    default $binary_remote_addr;
}

# log_format derp '[$time_local] "$http_host" >$rate_limit_except_discourse<';
# access_log /var/log/nginx/derp.log derp;

# rate limiting zones
limit_req_zone $rate_limit_except_discourse zone=flood:10m rate=15r/s;
limit_req_status 429;

limit_conn_zone $rate_limit_except_discourse zone=connperip:10m;
limit_conn_status 429;

# rate limiting zones are applied for all servers!
limit_conn connperip 20;
limit_req zone=flood burst=20 nodelay;

#=================================================

```

I create a new variable named `$rate_limit_except_discourse` in which, based on `$http_host` i enable or disable rate limiting: when `chat.tbp.land == $http_host` then `$rate_limit_except_discourse` will have the value `""` (_nothing_), and for all the other websites (by using the default keyword) i use the normal `$binary_remote_addr;`.

In this way I don’t have to copy-pasta the same lines in all my servers and the rate limiting is left for inner nginx (the one in the discourse container).

* * *

SUCCES! 😤

---

_[View the full topic](https://meta.discourse.org/t/discourse-socketed-outer-nginx-rate-limiting-when-opening-emoticons/96417)._
