CRITICAL FIXES: - Fixed JWT key configuration issue causing HTTP 500 on login - Changed environment variable from JWT_SECRET_KEY to Jwt__Key (double underscore) - Increased JWT key length to >32 bytes (256 bits) as required by HMAC-SHA256 - Fixed ASPNETCORE_URLS configuration (not ASPNETCORE_HTTP_PORTS) DOCUMENTATION CREATED: - TROUBLESHOOTING.md: Complete troubleshooting guide with common issues and solutions - deploy-littleshop.sh: Automated deployment script with working configuration - docker-compose.hostinger.yml: Docker Compose file with all correct environment variables - Updated WORKING_BASELINE_2024-09-24.md: Added HTTP 500 fix details ROOT CAUSES IDENTIFIED: 1. JWT key environment variable naming mismatch (Jwt__Key vs JWT_SECRET_KEY) 2. JWT key too short (was 17 bytes, needs >32 bytes) 3. ASP.NET Core URL configuration issue (ASPNETCORE_URLS vs HTTP_PORTS) 4. Database file permissions (must be owned by UID 1654) WORKING CONFIGURATION: - Jwt__Key with 79-byte key - ASPNETCORE_URLS=http://+:8080 - Proper Docker network configuration (littleshop-network) - SilverPay integration on port 8000 (not 8001) This commit ensures we have a stable, documented baseline for future updates and addresses the concern about "one step forward, two steps back" by providing comprehensive documentation of all fixes. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
4.6 KiB
4.6 KiB
LittleShop Troubleshooting Guide
Common Issues and Solutions
🔴 HTTP 500 Error on Login
Symptoms
- Login page loads (HTTP 200)
- Submitting credentials returns HTTP 500
- Error: "Request reached the end of the middleware pipeline"
Root Causes & Fixes
1. JWT Key Configuration Issue
Problem: JWT key environment variable name mismatch or key too short
Error Message:
IDX10720: Unable to create KeyedHashAlgorithm for algorithm 'http://www.w3.org/2001/04/xmldsig-more#hmac-sha256',
the key size must be greater than: '256' bits, key has '136' bits.
Solution:
# CORRECT - Use Jwt__Key (double underscore)
-e Jwt__Key="ThisIsAVeryLongSecretKeyThatIsDefinitelyLongerThan32BytesForSure123456789ABCDEF"
# WRONG - These won't work
-e JWT_SECRET_KEY="..." # Wrong variable name
-e Jwt_Key="..." # Single underscore
-e Jwt__Key="shortkey" # Key too short (< 32 bytes)
2. Parameter Case Sensitivity
Problem: Form sends lowercase but method expected uppercase
Solution: Already fixed in code - Login method now accepts both cases:
public async Task<IActionResult> Login(string Username, string Password)
{
var username = Username?.ToLowerInvariant();
var password = Password;
// ...
}
3. Port Configuration Issue
Problem: App listening on wrong port
Solution:
# CORRECT
-e ASPNETCORE_URLS="http://+:8080"
# WRONG
-e ASPNETCORE_HTTP_PORTS=8080 # This doesn't work
🔴 Container Shows "Unhealthy"
Symptoms
- Container running but marked as unhealthy
- Health check failing
Solution
- The health check includes database check which can timeout during initialization
- App still works even if marked unhealthy
- To disable health check issues, run without health check or increase timeout
🔴 Database Permission Errors
Symptoms
- SQLite Error 8: attempt to write a readonly database
- Cannot create or update database
Solution
# Database MUST be owned by UID 1654
sudo chown -R 1654:1654 /opt/littleshop/data/
🔴 Network Connectivity Issues
Symptoms
- Containers can't communicate
- SilverPay API unreachable
- "Name or service not known" errors
Solution
# All containers must be on littleshop-network
docker network connect littleshop-network littleshop-admin
docker network connect littleshop-network silverpay-api
docker network connect littleshop-network nginx-proxy-manager
🔴 Anti-forgery Token Validation Errors
Symptoms
- 400 Bad Request on form submissions
- CSRF token validation failures
Current Status
- Anti-forgery validation is temporarily disabled on login
- This is noted in the code:
// [ValidateAntiForgeryToken] // Temporarily disabled for HTTPS proxy issue
Quick Diagnostics
Check Container Status
docker ps --format "table {{.Names}}\t{{.Status}}" | grep littleshop
Check Logs for Errors
docker logs littleshop-admin --tail 50 | grep -E "Exception|ERROR|fail"
Test Login Locally
docker exec littleshop-admin curl -X POST http://localhost:8080/Admin/Account/Login \
-d "Username=admin&Password=admin" \
-o /dev/null -w "Status: %{http_code}\n"
Check Environment Variables
docker exec littleshop-admin printenv | grep -E "Jwt|ASPNETCORE"
Recovery Procedures
Complete Reset
# Stop everything
docker stop littleshop-admin
docker rm littleshop-admin
# Clean up
sudo rm -rf /opt/littleshop/data/*
# Fix permissions
sudo mkdir -p /opt/littleshop/{data,logs,uploads}
sudo chown -R 1654:1654 /opt/littleshop/data/
# Redeploy
./deploy-littleshop.sh
Emergency Development Mode
To see detailed errors:
docker run -d \
--name littleshop-admin \
--network littleshop-network \
-p 127.0.0.1:5100:8080 \
-v /opt/littleshop/data:/app/data \
-e ASPNETCORE_ENVIRONMENT=Development \
-e ASPNETCORE_URLS="http://+:8080" \
-e ConnectionStrings__DefaultConnection="Data Source=/app/data/littleshop-production.db" \
-e Jwt__Key="ThisIsAVeryLongSecretKeyThatIsDefinitelyLongerThan32BytesForSure123456789ABCDEF" \
littleshop:latest
Critical Configuration Points
Must-Have Environment Variables
ASPNETCORE_ENVIRONMENT=Production
ASPNETCORE_URLS=http://+:8080 # NOT HTTP_PORTS!
Jwt__Key=[minimum 32 bytes] # Double underscore!
ConnectionStrings__DefaultConnection=Data Source=/app/data/littleshop-production.db
Required Docker Network
littleshop-network (external)
Required Permissions
/opt/littleshop/data: UID 1654
/opt/littleshop/logs: UID 1654
/opt/littleshop/uploads: UID 1654