Questions tagged [setenvif]

The mod_setenvif module allows you to set internal environment variables according to whether different aspects of the request match regular expressions you specify. These environment variables can be used by other parts of the server to make decisions about actions to be taken, as well as becoming available to CGI scripts and SSI pages.

The mod_setenvif module allows you to set internal environment variables according to whether different aspects of the request match regular expressions you specify. These environment variables can be used by other parts of the server to make decisions about actions to be taken, as well as becoming available to CGI scripts and SSI pages.

29 questions
3
votes
0 answers

How to set an Authorization Header with Apache 2.4?

I'm currently developing a webmapping application. I'm using Apache 2.4, PHP, Javascript and Dojo (a javascript library used for mapping). Dojo is making request to webservices (hosted on https:// host/server/rest/services/... and managed by another…
3
votes
3 answers

How to use SetEnvIf with Request_URI when it is rewritten to index.php?

We have a drupal website a.com that is password protected. I want all a.com/api/... URIs not to be, though. So I've read about SetEnvIf: AuthName "Stage" AuthType Basic AuthUserFile ~/.htpasswd SetEnvIf Request_URI ".*data_sheets.*\.pdf"…
Alex
  • 9,911
  • 5
  • 33
  • 52
2
votes
1 answer

Is there a way to get client remote ip in appache config?

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…
DanCeg
  • 31
  • 4
2
votes
1 answer

SetEnvIfNoCase not setting variable value properly

I need to access service running at domain (example.com) from two different apps running at different ports of localhost but getting CORS error. PageURL accessed in browser is: http://localhost:8081/weather which internally sending AJAX request…
u tyagi
  • 732
  • 9
  • 18
2
votes
1 answer

Use SetEnvIf To Change A Variable Based Upon SSL_CLIENT_M_SERIAL Value

Webserver in question is... /usr/sbin/apache2 -v Server version: Apache/2.4.7 (Ubuntu) Server built: Mar 10 2015 13:05:59 Portions of httpd.x.conf file... SSLVerifyClient optional SSLVerifyDepth 3 SSLOptions +StdEnvVars +ExportCertData SetEnvIf…
kelvin0mql
  • 83
  • 1
  • 8
1
vote
1 answer

SetEnvIf Remote_Addr "x.x.x.x" doesn't work - Apache and DirecAdmin

I have a problem with DirectAdmin and firewall. The following statement doesn't work: SetEnvIf Remote_Addr "x.x.x.x" TRUST=yes Apache doesn't respond to above instruction. The instruction is part of the following whole: Alias /.well-known…
Maciej Osytek
  • 36
  • 1
  • 4
1
vote
0 answers

SetEnvIf - set variable based on another variable

So I'm trying to emulate AND with SetEnvIf to block/allow httpd access based on country and city. This is my block in my httpd conf: SetEnvIf RemoteHost "^" AllowEntry=0 SetEnvIf GEOIP_COUNTRY_CODE US AllowEntry=1 SetEnvIf GEOIP_REGION MA…
1
vote
0 answers

Create an Apache SetEnv variable with the value of a subclaim

I have an environment variable called FIRST and containing a JSON : { "claim1": "val1", "claim2": "val2" } I would like to set a new environment variable which should contain only val1. I tried to set this new variable (SECOND) using…
MaryC
  • 11
  • 2
1
vote
2 answers

How to make Apache stop log some my Urls

I have a Web Application. All requests to my app will pass to Root/index.php. Example: 1. http://myapp.com/?call=phpfile1.processSomething¶m1=x¶m2=y 2. http://myapp.com/?call=phpfile2.processSomethingElse 3.…
1
vote
1 answer

Setting various values by SetEnvIfNoCase is not working

I'm trying to filter some bots by blocking them in ".htaccess" file like this: #UniversalRules SetEnvIfNoCase User-Agent ^$ bad_bot #leave this for blank user-agents SetEnvIfNoCase User-Agent .*\@.* bad_bot SetEnvIfNoCase User-Agent .*bot.*…
Alexey Shatrov
  • 450
  • 4
  • 12
1
vote
1 answer

Apache mod_headers cannot unset header on a path

I am trying to set a header using mod_headers in Apache in all cases EXCEPT a certain path. I've tried each of the three variations below to do so, but none of them seem to work properly to exclude the path. In ALL cases I get the header for all…
1
vote
1 answer

Dynamic environment variable in .htaccess

I'm struggling to figure out how to get environment variables to work using SetEnvIf based off my scenario, and was wondering if somebody can tell me how to do it, or give an example. My outcome is that I need the following redirect to fire based…
owenmelbz
  • 6,180
  • 16
  • 63
  • 113
1
vote
1 answer

How to allow incoming traffic based on User-Agent Header field with Apache

I have read the documentation on Apache's setEnvIf and, using their example, written the following httpd config file designed to only allow requests from HTTP Header User-Agent=Doug SetEnvIfNoCase User-Agent Doug let_me_in
Jason Javier
  • 143
  • 1
  • 10
1
vote
1 answer

403 forbidden response still sends body

I set up my .htaccess file so that only certain IP ranges can access the /admin portion of my site, as asked in this question: Deny access to URI That works... in testing. When I tried this on my live, https enabled, site something strange…
Jelle De Loecker
  • 20,999
  • 27
  • 100
  • 142
1
vote
2 answers

Deny access to URI

I'm trying to deny access to a certain uri, namely /admin/ and have tried this .htaccess file: SetEnvIf Request_URI !^/admin/ not_admin_uri Order deny,allow Deny from all allow from 356.244.33. allow from env=not_admin_uri This works for the…
Jelle De Loecker
  • 20,999
  • 27
  • 100
  • 142
1
2