Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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

Those slanted dashes around the URLs can be removed.

share|improve this answer
    
Thanks. The slanted dashes were there to escape the ip addresses for posting here (guess I did it wrong). –  Pete Helgren Nov 22 '12 at 2:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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