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:

    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"

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
* Connected to prova.myserver.net ( 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>
  • Where exactly do you see ERR_INVALID_REDIRECT? – Tero Kilkanen Oct 12 '17 at 19:14
  • in the browser. – Paolo Benvenuto Oct 12 '17 at 21:34
  • Please show curl -v output for the request in your question. – Tero Kilkanen Oct 13 '17 at 4:27
  • answerd in body – Paolo Benvenuto Oct 13 '17 at 17:23
  • The issue here is that "\1" is not the correct backreference for your redirect destination. I don't know what is exactly the correct one with your software. It might be that the "" prevents the backreference from working or then there is something else that is used for the reference. – Tero Kilkanen Oct 14 '17 at 0:27

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:

  Port 80

      HeadRequire "Host:.*some1.myserver.net.*"
      Redirect "https://some1.myserver.net"

      HeadRequire "Host:.*some2.myserver.net.*"
      Redirect "https://some2.myserver.net"

  Port    443

  # first domain
  Cert "/etc/pki/tls/letsencrypt_pound/pound_some1.pem"
  # second domain
  Cert "/etc/pki/tls/letsencrypt_pound/pound_some2.pem"

  Disable SSLv3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.