Is there a way to get client remote ip in appache config?

Viewed 41

I have a folder "my_files" on my server (Apache 2.4.29 Ubuntu) that holds files with the client id as filename. Example: my_files/92.4.56.125

Now just clients with matching ip address should be allowed to download the corresponding file.

In appache2/sites-available/mydomaim.conf I added following lines:

SetEnvIf Request_URI "92.4.56.125" + "$"  owner_requesting
<Directory /home/server/my_files>
    Require env owner_requesting
</Directory>    

This works perfect. But the ip is still hardcoded. What I need, is the Remote_Addr variable. But I cannot figure out, how to dynamically assemble the regex string ("XX.X.XX.XXX$") during request time.

What I tried:

Remote_Addr + "$"

%{REMOTE_ADDR}e + "$"

"%{REMOTE_ADDR}e.$" ... many more variants.

Seems that Remote_Addr is not handeld over or available at all in this scope. Any Ideas?

0 Answers
Related