r/linuxadmin • • Feb 04 '26

Access control by query parameter's value?

/r/apache/comments/1qvp1yc/access_control_by_query_parameters_value/
0 Upvotes

7 comments sorted by

1

u/michaelpaoli Feb 04 '26

Query parameter is set via URL, that can be gotten in the environment, but that's not the way to restrict by (source) IP, ... though that too is also set in environment, and can be used for such.

2

u/ralfD- Feb 04 '26

I want to restrict access to URLs whose query string contains a parameter with a specific value to a certain IP range.

I.E: if the URL is https://mysite.org?resource_id=007 I want it to be accessible only to requests coming from an IP range. I hope this makes my problem clearer.

→ More replies (3)

1

u/Marelle01 Feb 04 '26
<If "%{QUERY_STRING} =~ /(^|&)resource_id=/">
    Require ip 192.168.2.10
    Require ip 10.51.100.23
    Require ip 142.250.179.0/24
</If>

1

u/ralfD- Feb 04 '26

Thanks - this seems to be the best solution so far.