# CSFR Error while login behind HA Proxy

**URL:** https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168
**Category:** Self-hosting
**Created:** [January 25, 2021, 1:16pm UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168 "2021-01-25T13:16:28Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![crospa91](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@crospa91](https://meta.discourse.org/u/crospa91)
#### Post date: [January 25, 2021, 1:16pm UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168/1 "2021-01-25T13:16:28Z")

</div>

Hi guys, I hope this is the right section to ask for help about this.  
I recently changed the reverse proxy I have in front of the discourse server.  
I have a server with several discourse installed and a reverse proxy on front that point domains to the right web server.

I’ve used HA Proxy on both setup but the difference it’s the platform, before it was installed in PFSense, and now on OPNSense.

The reverse proxy works perfectly but if I try to login I get the CSFR error and can’t really do anything.

nothing have changed in the discourse setup and the HA Proxy configuration is copied over so should be fine.  
I’ve turned on XforwardFor and SSL but still discourse don’t seems to keep the same IP from the client but sees only the one from the proxy.

This the reddit post where I’ve asked support as well: [Reddit - Please wait for verification](https://www.reddit.com/r/OPNsenseFirewall/comments/l4ltxb/migration_from_pfsense_to_opnsense_ha_proxy/?utm_source=share&utm_medium=web2x&context=3)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 25, 2021, 1:45pm UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168/2 "2021-01-25T13:45:26Z")

</div>

I don’t know if it’ll fix the csfr problem (which I think has to do with https certificate problems, but don’t really know), but the forwarded for boot your did by telling the nginx inside the container what addresses to trust. You can search here for X-forwarded-for and find examples of how to fix that.

---

<div class="post-metadata">

### Author: ![crospa91](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@crospa91](https://meta.discourse.org/u/crospa91)
#### Post date: [January 25, 2021, 2:19pm UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168/3 "2021-01-25T14:19:25Z")

</div>

Thanks for your reply.  
I had a look on the forum for that but can’t really find any updated information.

there is a bunch of old topics with the reference of Real\_ip to put in nginx inside the container, but I have no clue on how to do that.

do you suggest any specific guide?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [January 25, 2021, 2:47pm UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168/4 "2021-01-25T14:47:52Z")

</div>

I don’t see a specific guide, but I’ll try to create one soon. Here’s this [Inconsistent / missing registration & last IP - #13 by pfaffman](https://meta.discourse.org/t/inconsistent-missing-registration-last-ip/124386/13) that I think should give you what you need for the real-ip bit.

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [January 25, 2021, 3:39pm UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168/5 "2021-01-25T15:39:50Z")

</div>

> [@crospa91](#):
>
> XforwardFor and SSL

You need to send an `X-Forwarded-Proto` header as well.

---

<div class="post-metadata">

### Author: ![crospa91](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@crospa91](https://meta.discourse.org/u/crospa91)
#### Post date: [January 26, 2021, 10:01am UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168/6 "2021-01-26T10:01:54Z")

</div>

THANKS! Really I was 3 days I was running around in circles and this solved it!

I’ve added the Proto Header as well and it worked!

 ![Screenshot 2021-01-26 at 09.41.24](https://global.discourse-cdn.com/meta/original/3X/b/3/b38b0e7f52d8896cf8b13e050f740d8b265d3d8f.png)

---

<div class="post-metadata">

### Author: ![neounix](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/neounix/32/215617_2.png) [@neounix](https://meta.discourse.org/u/neounix)
#### Post date: [January 26, 2021, 10:07am UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168/7 "2021-01-26T10:07:02Z")

</div>

> [@crospa91](#):
>
> THANKS! Really I was 3 days I was running around in circles and this solved it!

FWIW, there are many example configurations for reverse proxy servers in front of the Discourse app, including this one, almost all address “X-Forwarded-Proto”:

> [@I want to install using a reverse proxy for Apache](https://meta.discourse.org/t/i-want-to-install-using-a-reverse-proxy-for-apache/158519/5):
>
> Dear @Teraterayuki … Here is an example set of working Apache2 virtual hosts for a reverse proxy to a unix domain socket in a Discourse container: Port 80 \<VirtualHost \*:80\> ServerName mysite.mydomain.com ServerAdmin webmaster@localhost ProxyPreserveHost On #ProxyPass / http://127.0.0.1:8888/ #ProxyPassReverse / http://127.0.0.1:8888/ # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, # error, crit, alert, emerg.…

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [February 25, 2021, 10:07am UTC](https://meta.discourse.org/t/csfr-error-while-login-behind-ha-proxy/177168/8 "2021-02-25T10:07:57Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
