You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2016/03/04 15:41:56 UTC

[Bug 59117] New: SetEnvIF cannot use backreferences for when parsing "HTTP_" environment variables

https://bz.apache.org/bugzilla/show_bug.cgi?id=59117

            Bug ID: 59117
           Summary: SetEnvIF cannot use backreferences for when parsing
                    "HTTP_" environment variables
           Product: Apache httpd-2
           Version: 2.4.18
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_setenvif
          Assignee: bugs@httpd.apache.org
          Reporter: apache_bugzilla@valgronda.com

In following example the backreference $1 is always empty when match occurs:

SetEnvIf HTTP_HOST "^(.*)(:.*)?" HTTP_HOST_NOPORT=$1

My use case is as follows:
- virtual host example.com on non standard http port
- virtual host example.com on non standard https port
- several SeverAliases are defined on both (example1, example2, etc)
- all http traffic should be redirected to https (also on non-standard port)

So I tried to configure

SetEnvIf HTTP_HOST "^(.*)(:.*)?" HTTP_HOST_NOPORT=$1
RewriteRule ^/(.*)$ https://%{ENV:HTTP_HOST_NOPORT}:4443/$1 [NC,R=301,L,NE]

This will result in a redirect with wrong "Location: https://:4443/" if a
request to http://example.com:8080 or http://example1.com:8080 is done.
Expected would be a "Location: https://example.com:4443" or "Location:
https://example1.com:4443" (according to the server alias used for the request)

This behavior with HTTP_ environment variables of SetEnvIf is in contrast to
e.g.

SetEnvIf REQUEST_URI "\.(.*)$" EXTENSION=$1

In that example you can use %{ENV:EXTENSION} in a RewriteRule.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59117] SetEnvIF cannot use backreferences for when parsing "HTTP_" environment variables

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59117

Eric Covener <co...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID

--- Comment #1 from Eric Covener <co...@gmail.com> ---
Multiple issues in your SetEnvIf. Try

SetEnvIf HOST "^([^:]*)" HTTP_HOST_NOPORT=$1

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


[Bug 59117] SetEnvIF cannot use backreferences for when parsing "HTTP_" environment variables

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=59117

--- Comment #2 from nada <ap...@valgronda.com> ---
Wow, thanks for the hint Eric.

Use "HOST" instead of "HTTP_HOST" solved the problem (I had also tested with
SetEnvIf HTTP_HOST "(.*)" - but this match was of course also empty every
time...)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org