1

I have seen different flavors of this but nothing that clearly matches what I need to do. I have an Apache server with a wildcard cert installed. Now I want Apache to do two things:

1) Listen for requests on http and permanently request https for each site. 2) Proxy that https request to internal servers who are listening only on port 80.

I am pretty sure that I will have multiple virtual host entries and lets assume that the CNames are www.mydomain.com, test.mydomain.com, staging.mydomain.com. All of them point to the same IP which is my Apache server.

So when a request comes in for http://www.mydomain.com it should be redirected to https://www.mydomain.com and then proxied to an internal server at 192.168.20.200. A request for http://test.mydomain.com should be redirected to https://test.mydomain.com and proxied back to 192.168.20.201...and so on.

As best I can guess the virtual hosts for www.mydomain.com should be something like:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.mydomain.com
Redirect permanent / `https://www.mydomain.com/`
</VirtualHost>

<VirtualHost *:443>
ServerName www.mydomain.com
ProxyPass / `http://192.168.20.200/`
ProxyPassReverse / `http://192.168.20.200/`
</VirtualHost>

I am uncertain as to whether this is the correct approach (I have seen some examples using rewrites) and I am not certain that I need TWO virtual host entries per domain.

Can someone verify that this is the correct approach? This Apache will be the reverse proxy for multiple hosts at this domain.

1 Answer 1

1

You have the correct setup for what you are trying to do.

Those slanted dashes around the URLs can be removed.

1
  • Thanks. The slanted dashes were there to escape the ip addresses for posting here (guess I did it wrong). Nov 22, 2012 at 2:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .