I have a server (debian jessie) managing multiple domains with varnish and apache, and I want to use pound in order to redirect http traffic to https.
Since the HeadRequire directive permits a regex, I'm trying with a regex in Redirect too:
ListenHTTP
Address 1.2.3.4
Port 80
## allow PUT and DELETE also (by default only GET, POST and HEAD)
xHTTP 0
RewriteLocation 0
Service "myHost"
HeadRequire "^Host: (.+)\.myserver\.net"
Redirect 301 "http://\1.myserver.net"
End
End
but unfortunatly I get ERR_INVALID_REDIRECT
Is there a way to let pound do wildcard redirect?
Curl output:
$ curl -v http://prova.myserver.net:80/
* Hostname was NOT found in DNS cache
* Trying 1.2.3.4...
* Connected to prova.myserver.net (1.2.3.4) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: prova.myserver.net:80
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 301 Moved Permanently
< Location: http://%5c1.myserver.net/
< Content-Type: text/html
< Content-Length: 148
<
* Closing connection 0
<html><head><title>Redirect</title></head><body><h1>Redirect</h1><p>You should go to <a href="http://%5c1.myserver.net/">here</a></p></body></html>
Best Answer
In short: not possible.
Based on pound documentation the Redirect directive does not allow for any patterns (or regexes). And this also follows logically from the fact that there may be many HeadRequire directives per service (all of them should be satisfied for the Redirect to work), so if you used two HeadRequire directives with different regexes, there's no way for Redirect to guess which of them has the backreference you want.
You also asked about redirecting to https, but your example redirects to http. You probably omitted the "s" as in: