Apache2 proxy if url is 1:1 correct

Hyp3r

New Member
Joined
Dec 16, 2023
Messages
2
Reaction score
0
Credits
26
Hello, this is my current Apache2 VHost:
Apache config:
<VirtualHost *:80>
  ServerName url.tld
  DocumentRoot /var/www/html

  <Location "/pihole/api.php">
    <If "%{REQUEST_URI} =~ m#/pihole/api.php# && %{QUERY_STRING} =~ m#&auth=code#">
      Require all granted
      SetEnv CORS_HOSTS request-url.tld
    </If>
  </Location>

  <LocationMatch "^(?!/font|/files).*">
    Require all denied
    ErrorDocument 403 "Error"
  </LocationMatch>

  Alias "/font" "/var/www/fonts"
   <Directory "/var/www/fonts">
       Require all granted
       Header set Access-Control-Allow-Origin "*"
       RewriteEngine On
       RewriteCond %{QUERY_STRING} !auth=authcode
       RewriteRule ^ - [F]
       RewriteRule ^ - [L]
       ErrorDocument 403 "Error"
   </Directory>

   Alias "/files" "/var/www/files"
   <Directory "/var/www/files">
       Require all granted
       Header set Access-Control-Allow-Origin "*"
       RewriteEngine On
       RewriteCond %{QUERY_STRING} !auth=authcode
       RewriteRule ^ - [F]
       RewriteRule ^ - [L]
       ErrorDocument 403 "Error"
   </Directory>
</VirtualHost>
It is explicitly about the first part, this one: [I have posted everything as there may be incompatibilities]
Apache config:
<Location "/pihole/api.php">
    <If "%{REQUEST_URI} =~ m#/pihole/api.php# && %{QUERY_STRING} =~ m#&auth=code#">
      Require all granted
      SetEnv CORS_HOSTS request-url.tld
    </If>
</Location>
I would like that if the URL is 1:1 [!!!] like this [except the variable, which should not matter]: https://url.tld/pihole/api.php?<variable>&auth=code is "proxyed" to this specific url: http://ip:port/admin/api.php?<variable_from_requesturl>&auth=code

What should the part look like then?
 

Members online


Latest posts

Top