Wrong user when behind reverse proxy
Something very strange happens when I am behind a reverse proxy (nginx). I log in to immich using a non-admin user and immich gets connected to the admin account.
That doesn't happen if I connect to immich thru the local lan.
Any idea on why that happens?
14 Replies
Can someone point me how immich authenticate the users? Somehow my proxy server is forwarding a wrong information to immich. Is it thru cookie?
What’s your proxy config
Is it the same on different browsers
This problems happens in multiple browsers, different computers and different android apps. Since it works fine on LAN, I suspect it is a problem in reverse proxy. See my nginx config below:
You probably don't want the set header cookie line in there
I'm guessing that is copying the session from the first login request made to the server and putting it on all future requests.
@jrasm91 , thank for you comment, but this is not the issue because I added that after multiple attempts without this line
Are you restarting Nginx after making changes?
The issue you are describing is non-standard behavior so you most likely have something misconfigured. To me the cookie header looks obviously wrong so you should remove and revalidate it either way
You were right. I could solve it, but I have no idea how. I just started a new nginx config from scratch. Thank you for your help
My problem was with caching. I solved it by disabling cache in nginx:
Interesting... Maybe it was caching the json responses.
That’s so weird because the session id should change and it should invalidate the cache
The cookie header should not impact the caching of responses should it?
Looks like the default cache key is just the url
proxy_cache_key $scheme$proxy_host$request_uri;
I guess they assume people using cookies will know to have their proxy invalidate cache properly 🤷🏽♂️
You could include it in your cache key.
Yeh I mean they assume people using cookies will set their cache keys to properly invalidate it
Maybe we can just add the cache key to the nginx config
I have cache enabled for another web app I use. Somehow this may have affected my immich server block. Maybe it is a good idea to add directives disabling cache in the example to avoid problems in initial setup as I had faced. Then the user who knows what he is doing can disable according to their needs.
I can confirm that the moment I disabled cache as in my previous post, immich started to work fine, logging to the correct user.