I was having some issues with this as well. Here is a link that helped me. If I get to a console I will upload exactly what worked for me.
Thank you. Unread through the discussion using the link provided, but it still appears to be an ongoing, open issue for folks. I'll be curious to see which solution worked best for you.
Just hard code Connection to upgrade
I had this same problem, and some back and forth between ChatGPT and digging around in NPM’s files it seems that the advanced config in NPM is only a section of the full nginx config, so some directives aren’t available due to the scope.
What I did was just copy-paste the config into ChatGPT and ask it to rewrite it without using the map directive. It immediately spat out a working config. Of course I reviewed it manually to make sure it didn’t muck with the rest of the config.
As someone really new to this myself, using a tool like GPT can help you gain a lot of context for problems because even if it isn’t always perfect. Sometimes it spits out a nugget that gets you thinking about how to approach the problem differently.
Edit: Here was how ChatGPT modified the code.
Here are the key changes I made to address the map directive issue and replace it with conditional logic inside the location block:
Removed the map directive:
I removed this section:
# Upgrade WebSocket if requested, otherwise use keepalive map $http_upgrade $connection_upgrade_keepalive { default upgrade; ‘’ ‘’; }
Replaced $connection_upgrade_keepalive with $http_connection and conditional logic:
In the original config, you were using $connection_upgrade_keepalive, which was set by the map directive. To replace this, I added the following logic inside the location block:
# Support for websocket proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $http_connection; # Use conditionals to handle WebSocket or keepalive if ($http_upgrade = “websocket”) { set $http_connection “upgrade”; } if ($http_upgrade = “”) { set $http_connection “keep-alive”; }
Other Changes:
In the original code, you were setting the Connection header using $connection_upgrade_keepalive, but since we removed the map directive, we use $http_connection here instead.
This is the main change to ensure that the configuration handles WebSocket upgrades or defaults to keep-alive, without using the map directive. Everything else remains as it was.
Many thanks, will try this
I also noticed that the token timeout is not working I want to set 2 hours token lifetime; cookie will expire on UTC-time + 2 hours (my current timezone is UTC+2) then I tried adding 10 minutes extra and waited
Local time on my computer was 17:10 cookie expiration was 17:08 (date matched current date) I tried adding max lifetime through NPM but this did not work either
I saw an issue on Github which has been flagged as Bug, any chance you know something about that?