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...

Lokomotywa
  • 2,624
  • 8
  • 44
  • 73
  • Sounds like a [X-Y-problem](https://meta.stackexchange.com/q/66377/364505) 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/on-topic]) – Olaf Kock Jun 22 '22 at 14:20
  • I am trying to achieve this: Require all denied – Lokomotywa Jun 22 '22 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. – Lokomotywa Jun 22 '22 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. – Lokomotywa Jun 22 '22 at 14:29
  • The original question just seemed to be to complicated (or asked at the wrong place) https://stackoverflow.com/questions/72710895/apache-deny-non-local-requests-that-match-a-specific-url-pattern – Lokomotywa Jun 22 '22 at 14:32
  • There seems to be something really confusing about my question. I would expect it to have a very simple solution, but nobody answers. Enlightening me about the things I probably misunderstand is also highly appreciated. – Lokomotywa Jun 22 '22 at 16:39

1 Answers1

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.
hugomztl
  • 88
  • 11
  • Is there a way to observe the values of these variables? – Lokomotywa Jun 23 '22 at 09:23
  • I have already checked the provided link but it's about something different. – Lokomotywa Jun 23 '22 at 09:24
  • 1
    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"];` – hugomztl Jun 23 '22 at 09:27
  • 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. – hugomztl Jun 23 '22 at 09:33