# Troubleshooting "BAD CSRF" error on initial site setup?

**URL:** https://meta.discourse.org/t/troubleshooting-bad-csrf-error-on-initial-site-setup/97059
**Category:** Self-hosting
**Created:** [September 12, 2018, 5:23pm UTC](https://meta.discourse.org/t/troubleshooting-bad-csrf-error-on-initial-site-setup/97059 "2018-09-12T17:23:19Z")
**Posts on this page:** 1
**Showing post:** 17

<div class="post-metadata">

### Author: ![fais3000](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fais3000/32/218714_2.png) [@fais3000](https://meta.discourse.org/u/fais3000)
#### Post date: [April 29, 2021, 9:17pm UTC](https://meta.discourse.org/t/troubleshooting-bad-csrf-error-on-initial-site-setup/97059/17 "2021-04-29T21:17:52Z")

</div>

For anyone else banging their head facing this issue. Please read below.

I was having similar issue. In my case we are behind Cloudflare, then Nginx and the setup was for a forum on subfolder.

Ultimately following combination worked.

- Disabling caching for the subfolder on Cloudflare
- Following Nginx block

```plaintext
    location /folder {
        proxy_ssl_server_name on;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_pass http://localhost:1357/folder;
    }

```

---

_[View the full topic](https://meta.discourse.org/t/troubleshooting-bad-csrf-error-on-initial-site-setup/97059)._
