# Safe-mode returns \["BAD CSRF"\] with reverse proxy

**URL:** <https://meta.discourse.org/t/safe-mode-returns-bad-csrf-with-reverse-proxy/174210>\
**Category:** Self-hosting\
**Tags:** unsupported-install\
**Created:** [December 24, 2020, 4:42pm UTC](https://meta.discourse.org/t/safe-mode-returns-bad-csrf-with-reverse-proxy/174210 "2020-12-24T16:42:41Z")\
**Posts on this page:** 1\
**Page:** 1

## AI-generated summary

[pfaffman](/t/-/174210/1) is debugging an AWS Discourse installation that functions correctly on the production site but encounters issues when an additional NGINX reverse proxy is introduced for redirections. The primary symptom is that Single Sign-On (SSO) logins fail to persist, appearing as if the login did not occur. Additionally, attempting to enable safe mode results in a `BAD CSRF` error. The user suspects this CSRF issue may be related to the broader problem caused by the reverse proxy configuration and is seeking guidance on where to investigate next. They also reference a related troubleshooting thread regarding `BAD CSRF` errors during initial site setup.

<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:** [December 24, 2020, 4:42pm UTC](https://meta.discourse.org/t/safe-mode-returns-bad-csrf-with-reverse-proxy/174210/1 "2020-12-24T16:42:41Z")

</div>

I’m helping debug an AWS installation that’s working fine on the current production site.

For Reasons, they want to have an additional NGINX as a reverse proxy to handle some redirections. When the NGINX is added SSO logins don’t work; it as if the login didn’t happen.

When trying [safe mode](https://meta.discourse.org/t/53504?silent=true), I get a `BAD CSRF` after submitting the request to enable [safe mode](https://meta.discourse.org/t/53504?silent=true).

I’m not sure if this might be part of the problem we’re trying to solve, but it definitely seems like a problem.

I’m not sure where to look next.

EDIT: Here’s this:

> [@Troubleshooting "BAD CSRF" error on initial site setup?](https://meta.discourse.org/t/troubleshooting-bad-csrf-error-on-initial-site-setup/97059/5):
>
> This happens when SSL is badly configured. Most of the times a header is missing from the reverse proxy config.
