Redirect all requests to https://www version with Pound proxy

pound

I am trying to configure Pound proxy configuration file to redirect all requests to a website over http to https://www.example.com. Also I need requests coming to https://example.com to be redirected to https://www.example.com.

I have the following code so far and it works:

ListenHTTP
    Address xx.xx.xx.xx
    Port 80

  Service
      HeadRequire "Host:.*example.com.*"
      Redirect "https://www.example.com"
  End

End

Service
    BackEnd
        Address xx.xx.xx.xx
        Port    8888
    End
End
ListenHTTPS
  Cert "/home/path/to/subdomain/ssl.everything"
  Cert "/home/example/ssl.everything"
  Address xx.xx.xx.xx
  Port    443
  HeadRemove "X-Forwarded-Proto"
  AddHeader "X-Forwarded-Proto: https"
  Ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384..."
        Service
            URL     "^(/|.*)$"
            Redirect "https://www.example.com"
        End
End

However, I can't figure out how to make the rule in ListenHTTP:

  Service
      HeadRequire "Host:.*example.com.*"
      Redirect "https://www.example.com"
  End

respect other sub-domains of the same domain. Currently unfortunately all the sub-domains also are getting redirected to https://www.example.com.

The same problem for the rule in ListenHTTPS part. It redirects all the requests to https://www.example.com:

        Service
            URL     "^(/|.*)$"
            Redirect "https://www.example.com"
        End

whereas I need only https://example.com to be redirected to https://www.example.com.

What should be right patterns for bot ListenHTTP and ListenHTTPS blocks to leave out all other domains and sub-domains on the same IP?

Best Answer

Keep in mind: The 1st rule to apply WILL be applied! Basicly you should make a Wildcard-Rule on the very End of the Rule-List.

Related Topic