Req and user empty when running behind NGINX reverse proxy #1568
Replies: 8 comments
-
Have you set https://payloadcms.com/docs/production/preventing-abuse#rate-limiting-requests |
Beta Was this translation helpful? Give feedback.
-
Will try it |
Beta Was this translation helpful? Give feedback.
-
Note though @DanRibbens that I have not set rateLimits whatsoever on my production server... Because I didn't know such a thing existed lmao. Anyway, unless there is a default rateLimit, and that rateLimit is being exceeded due to interactions with the reverse proxy I odnt think that is the problem. But will try it anyway, will try it tmr. But the docs are a bit ambiguous, I don't know if the trustProxy option enables requests going through nginx in general, whereas by default they are disabled all together, or it increases the limit for the ratelimit. The docs kind of imply it does the latter, but explicitly states the former. |
Beta Was this translation helpful? Give feedback.
-
Alright just tried it now, doesn't work unfortunately |
Beta Was this translation helpful? Give feedback.
-
I don't think this is related to I'm going to convert this to a discussion, but if you can share your nginx config, maybe we can identify the problem! |
Beta Was this translation helpful? Give feedback.
-
the evcs-frontend and payload-cms names are used because those are the container process names in the docker compose |
Beta Was this translation helpful? Give feedback.
-
Ok guys I just realized... Its not the Nginx reverse proxy that was wrong, I turned off the nginx and went to the port and it still doesn't work. Menaing, there is just plainly no request body for some odd reason |
Beta Was this translation helpful? Give feedback.
-
I know I am late for this discussion, but if someone in the future stumbles upon this thread like I did: Make sure that your
to
might fix that problem. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Bug Report
When using Nginx reverse proxy, req is empty, and thus req.user is undefined. This means access controls get scuffed. So you will never be allowed to do anything... Even logging out even if you are admin.
Strangely, with the way I have configured things the initial login works, but logging out doesn't.
Steps to Reproduce
##Important details
get requests seem to sort of work (In the chrome dev tools network tab, there are 2 requests made to each endpoint, one gets 403 and one gets 200)
Post requests somehow don't due to empty req.
Other Details
If you used a port in your serverUrl and reverse proxy to that, you won't even see the admin panel, and the same error occurs but worse, req will still be empty, but will even be empty for the initial /api/access fetch request when logging in.
Without a port, by just setting serverUrl to http://localhost , /api/access works normally, but everything you do post login is rekt.
More info gained from this discussion
Everything works on local
rateLimit.trustProxy = true doesn't fix it
Beta Was this translation helpful? Give feedback.
All reactions