0

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?

Nick
  • 205
  • 1
  • 8
  • https://serverfault.com/questions/582906/pound-url-redirect-with-negative-pattern-wouldnt-match – Orphans Mar 13 '18 at 08:53
  • Thanks, but that page is about redirecting https to http. Using the redirect rule in ListenHTTP gives the same result as above - it doesn't take care of desired effect. – Nick Mar 13 '18 at 14:10
  • The principle is the same, you can rewrite the rule as you want. Basically - do HTTP to HTTPS redirection first, and then do @ to www. – Orphans Mar 17 '18 at 21:37
  • Easy to say than implement. I wouldn't bring it here if various approaches were not failing. Mind sharing real code based on the provided above? – Nick Mar 19 '18 at 15:45

1 Answers1

0

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.