<commit_before>---
layout: post
title: "Get user real ip in nginx behing nginx reverse proxy"
excerpt: "Behind a reverse proxy, the user IP we get is often the reverse proxy IP itself. But for obvious reasons it's important to have access to the user real ip address."
tags: [nginx, reverse, proxy, real, ip, address, user, headers, log, format, x-forwarded-for, x-forwarded-proto, x-real-ip]
image: nginx.png
comments: true
---

Behind a reverse proxy, the user IP we get is often the reverse proxy IP itself. But for obvious reasons it's important to have access to the user real ip address.

![Docker](/images/posts/nginx.png)

# Nging reverse proxy configuration

_Tested for nginx/1.11.8_

The `http_realip_module` must be installed (`--with-http_realip_module`), of course !

Use this command to check :

```
2>&1 nginx -V | tr -- - '\n' | grep http_realip_module
```

* We need to tell the reverse proxy to pass information to the backend nginx server.
* We can add thoses lines as a global configuration or per location.<commit_msg>fix typo<commit_after>---
layout: post
title: "Get user real ip in nginx behind nginx reverse proxy"
excerpt: "Behind a reverse proxy, the user IP we get is often the reverse proxy IP itself. But for obvious reasons it's important to have access to the user real ip address."
tags: [nginx, reverse, proxy, real, ip, address, user, headers, log, format, x-forwarded-for, x-forwarded-proto, x-real-ip]
image: nginx.png
comments: true
---

Behind a reverse proxy, the user IP we get is often the reverse proxy IP itself. But for obvious reasons it's important to have access to the user real ip address.

![Docker](/images/posts/nginx.png)

# Nging reverse proxy configuration

_Tested for nginx/1.11.8_

The `http_realip_module` must be installed (`--with-http_realip_module`), of course !

Use this command to check :

```
2>&1 nginx -V | tr -- - '\n' | grep http_realip_module
```

* We need to tell the reverse proxy to pass information to the backend nginx server.
* We can add thoses lines as a global configuration or per location.
{'fraction_non_alphanumeric': 0.09060240963855422, 'fraction_numerical': 0.005783132530120482, 'mean_word_length': 4.088235294117647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4044749', 'n_tokens_mistral': 645, 'n_tokens_neox': 616, 'n_words': 300}