0

I have some difficulties to understand the apache variables described in here:

https://httpd.apache.org/docs/2.4/expr.html#vars

What I need to use in my directive:

  1. The IP of the webserver the apache is running on

  2. The IP of the client trying to access the server

  3. The URL (string) the client is trying to access

  4. Alternatively, a boolean telling me whether the current request is coming from the server itself


As far as I understand, REMOTE_ADDR must be the client's IP. But where is the Servers ID hidden? SERVER_ADDR does not exist...

6
  • Sounds like a X-Y-problem to me. What are you actually trying to achieve, what have you tried so far and what did you observe with your tries? The way the question currently is phrased, I consider it as "asking for documentation", which is off-topic (help center) Commented Jun 22, 2022 at 14:20
  • I am trying to achieve this: <If "%{CLIENT_IP} != %{SERVER_IP}"> Require all denied </If> Commented Jun 22, 2022 at 14:26
  • I try to achieve this by finding the correct variables to use since I assume the config must be aware of the ip of the system it is running on. Commented Jun 22, 2022 at 14:28
  • I did not observe anything besides "it does not work" since there is (to me) no known way to "oberve" expressions within apache config. Commented Jun 22, 2022 at 14:29
  • The original question just seemed to be to complicated (or asked at the wrong place) stackoverflow.com/questions/72710895/… Commented Jun 22, 2022 at 14:32

1 Answer 1

1
  1. SERVER_ADDR depending if your server provide it, else try HTTP_HOST
  2. REMOTE_ADDR
  3. REQUEST_FILENAME/REQUEST_URI
  4. There is no native function provided by Apache doing that but I let you check this topic you may find what you looking for.
Sign up to request clarification or add additional context in comments.

4 Comments

Is there a way to observe the values of these variables?
I have already checked the provided link but it's about something different.
Its because HTTP_HOST probably contain the port number while REMOTE_ADDR don't. You can see these value simply by a little PHP line echo $_SERVER["HTTP_HOST"]." ".$_SERVER["REMOTE_ADDR"];
For exemple, on my server I got 192.168.200.152:8008 for HTTP_HOST and 192.168.200.152 for REMOTE_ADDR. Regarding the 4. I'm sorry but I can't figure out how to do that.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.