Immich Login Hangs/Freezes Behind Nginx Reverse Proxy - Cookie Directive Bug Fix #19020
Goluff
started this conversation in
Community Guides
Replies: 1 comment
-
Thank you and your kind soul. Add 4 hours to the counter of time spent debugging this issue! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Problem Description - Symptoms You May Experience
Environment Details
Root Cause Analysis
The issue is caused by Nginx
proxy_cookie_path
directive that duplicates cookie security flags, causing browsers to reject or mishandle authentication cookies.What’s Happening Behind the Scenes
Normal Immich Cookie (working direct access):
Set-Cookie: immich_access_token=abc123; Max-Age=34560000; Path=/; HttpOnly; SameSite=Lax
Broken Cookie Through Nginx (with problematic directive):
Set-Cookie: immich_access_token=abc123; Max-Age=34560000; Path=/; HTTPOnly; Secure; HttpOnly; Secure; SameSite=Lax
Notice the duplicated
HTTPOnly; Secure
flags that break cookie parsing.The Fix - Remove Problematic Nginx Directive
Locate the Problem Directive
Search your Nginx configuration files for this line:
Common locations:
/etc/nginx/conf.d/ssl.conf
/etc/nginx/snippets/ssl-params.conf
/etc/nginx/sites-available/immich.conf
/etc/nginx/conf/ssl_server.conf
Solution 1: Remove the Directive (Recommended)
Simply comment out or delete the problematic line:
# proxy_cookie_path / "/; HTTPOnly; Secure"; # COMMENTED OUT - CAUSES IMMICH LOGIN ISSUES
Solution 2: Fix the Directive (If You Need It)
If you specifically need to add cookie security flags:
Apply the Fix
Why This Happens
HttpOnly
,Secure
,SameSite
)Debugging Steps That Led to Discovery
1. WebSocket Testing
2. Network Request Analysis
3. Created Test Application
Built simple Node.js + Socket.IO app to verify WebSocket functionality through reverse proxy (worked perfectly).
Related Issues and Solutions
If You’re Still Having Problems:
Check Content Security Policy headers - may block JavaScript execution
Verify IMMICH_TRUSTED_PROXIES includes your reverse proxy IP
Ensure WebSocket upgrade headers are properly configured:
Complete Working Nginx Configuration Example
Prevention for Other Applications
This issue can affect any web application that:
proxy_cookie_path
directive with duplicated flagsApplications potentially affected:
Additional Keywords for Search Engines
nginx proxy_cookie_path duplicate flags
,nginx set-cookie header malformed
,reverse proxy authentication cookies broken
,nginx ssl cookie httponly secure duplicate
,immich docker nginx login problem
,immich podman systemd nginx issue
,immich rootless container reverse proxy
,nginx cookie rewrite causes login failure
,immich nginx ssl termination login bug
,immich nginx reverse proxy login not working
,immich login hangs https
,immich authentication infinite loading
,immich nginx ssl login broken
,immich reverse proxy websocket failed
,immich login button unresponsive
,immich proxy cookie problem
Time spent debugging this issue: ~8+ hours including custom test application development
Root cause: Single Nginx directive duplicating existing cookie security flags
Fix complexity: Comment out one line
Prevention: Let applications handle their own cookie security flags
Beta Was this translation helpful? Give feedback.
All reactions