Using nginx as a reverse proxy with long connections enabled, the CWMP (CPE WAN Management Protocol) logs show “invalid session”.
When only a single device is connected, it works fine, but concurrency leads to “invalid session” errors. I’ve traced the code and found that the context is bound to the socket. Long connections between nginx and CWMP seem to be managed through a connection pool. When connections are idle, they can be assigned to other devices, leading to context mix-ups.
If long connections aren’t enabled, digest authentication fails to retrieve the corresponding token, resulting in unsuccessful authentication.
Do you have any elegant nginx configuration to share, or any other solutions?
my nginx.conf:
upstream CWMP_BACKEND {
server 127.0.0.1:37547 weight=1 max_fails=2 fail_timeout=30s;
keepalive 300;
}
server {
listen 80;
client_body_buffer_size 5m;
location / {
proxy_pass http://CWMP_BACKEND;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}