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 client ip at request time. But I cannot figure out, how to use Remote_Addr.
The following does not work:
SetEnvIf Remote_Addr "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$" IPSTR=$1
SetEnvIf Request_URI IPSTR + "$" owner_requesting
<Directory /home/server/x3d_files>
Require env owner_requesting
</Directory>
I checked IPSTR by passing it to header and it returned the correct IP.
Maybe SetEnvIf Request_URI is processed earlier, when SetEnvIf Remote_Addr ist not yet evaluated?
Any Idea?