0

I am actually building a webdav server using nginx behind a Traefik and Authelia as middleware for ldap auth. I confirmed with debugging that both the variables $http_remote_user and $http_remote_groups exists and contained data. However on startup nginx throw me that error saying

[emerg] 1#1: unknown "remote_groups" variable

I am sure the line that causes that is the line

sub_filter '${REMOTE_GROUPS}' $http_remote_groups;

of the following config since removing it from the config solve the problem. The thing is that I need this for my index.html to get the user uid and groups.

Here is the part of the config that causes the crash. I can provide more if needed :)

###### ROOT DIRECTORY ######
location / {

    # Refuse all methods except GET
    limit_except GET {
        deny all;
    }

    # Prevent access to hidden files
    location ~ /\. {
        deny all;
        return 404;
    }

    # Root path
    root /media/data;

    # Use sub_filter to replace placeholders with actual values
    sub_filter '${REMOTE_USER}' $http_remote_user;
    sub_filter '${REMOTE_GROUPS}' $http_remote_groups;
    sub_filter_once off;
}

jsotola
  • 340

1 Answers1

0

That was bad choice for placeholder. I would recommend to change it to something without dollar sign.

But there is a weird solution (based on this answer on SO). We have to put dollar into a variable. To do this, we'll use geo module, because geo module values cannot contain variables, nginx will not try to extrapolate $ there.

geo $dollar {
  default "$";
}

server { ... sub_filter '${dollar}{REMOTE_USER}' $http_remote_user; sub_filter '${dollar}{REMOTE_GROUPS}' $http_remote_groups; }

Alexey Ten
  • 1,639
  • 2
  • 12
  • 8