[MapServer-users] Pass Apache variable for MaServer Layer

Eduardo Kanegae eduardo.kanegae at gmail.com
Mon Jun 2 08:06:54 PDT 2025


hi,

I'm running MapServer 8 under Debian 12/Apache 2.4 and PostgreSQL
17.5/PostGIS 3.5
and W*S already authenticated using auth/dbd under Apache/SSL, which works
fine with:

Alias /my_wms_link /path/to/mapserv.fcgi
<Location /my_wms_link>
   SetHandler cgi-script
   AddHandler fcgid-script .fcgi
   Options ExecCGI Indexes FollowSymLinks
   SetEnv MAPSERVER_CONFIG_FILE /etc/mapserver8.conf
   SetEnv MS_MAPFILE /var/mapserver/etc/my_mapfile.map
   Require all denied
   AuthBasicProvider dbd
   AuthName "Login needed!"
   AuthType Basic
   Require valid-user
   AuthDBDUserPWQuery "SELECT u.passwd, u.login_name FROM table_users u
WHERE u.login = %s"
</Location>

But, I'm wondering if it is possible to define an apache variable here, in
.conf apache, and then to read/access this variable at layer level in
MapFile. eg.: to pass the userLoginName for
Layer->Processing(NATIVE_FILTER) and then load only specific set of data
for the given user.
I tried  " SetEnv ms_user %{AUTH_USER}  " or %{AUTH_USER};

By now, the only way I got it was using alternative 2 CGI script from
https://mapserver.org/cgi/wrapper.html with
. . .
QUERY_STRING="ms_user=${REMOTE_USER}&${QUERY_STRING}"
exec ${MAPSERV}

Or Apache mod_rewrite would be better in this case?


Eduardo Kanegae
https://180hs.com.br/en
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20250602/70453839/attachment.htm>


More information about the MapServer-users mailing list