Solved

Using Apache2 to reroute 80 and 443 for various sites

Posted on 2012-03-18
1
599 Views
Last Modified: 2012-03-20
Howdy!

I have an Ubuntu server running Apache2. I would like to use it as a proxy for forwarding traffic from an external IP to different machines hosting different websites.

I can get websites on either 80 or 443 forwarding to different sites but not both at the same time. For instance, if I set up all my virtualhost rules for *.80 the *.443 virtualhost rules don't work.

I'm new to apache2 so I don't really know what I'm doing, just compiling information from various sources.

The default file in /etc/apache2/sites-available/ looks like this:

NameVirtualHost *:80

<VirtualHost *:80>
        ServerAdmin administrator@site1.com
        DocumentRoot /var/www/site1
        ServerName www.site1.com
        ServerAlias site1.com *.site1.com
        ErrorLog /var/log/site1_error.log
        CustomLog /var/log/site1_custom.log common

</VirtualHost>

<VirtualHost *:80>
	DocumentRoot /var/www/site2
	ServerName www.site2.com
	ServerAlias site2.com *.site2.com
	ErrorLog /var/log/site2_error.log
	CustomLog /var/log/site2_custom.log common

</VirtualHost>

<VirtualHost *:80>
	ServerName www.site3.com
	ProxyPreserveHost On
	ProxyPass / http://192.168.1.1/
	ProxyPassReverse / http://192.168.1.1/
	ServerAlias site3.com

</VirtualHost>

NameVirtualHost *:443

<VirtualHost secure.site4.com:443>

	#########################################################
	# SUBDOMAIN STUFF - BEGIN					#
	#########################################################

	ProxyPass	 /subdomain1	https://192.168.1.2/subdomain1/
	ProxyPassReverse /subdomain1	https://192.168.1.2/subdomain1/

	ProxyPass	 /subdomain2	https://192.168.1.3/subdomain2/
	ProxyPassReverse /subdomain2	https://192.168.1.3/subdomain2/

	ProxyPass	 /subdomain3		https://192.168.1.4/subdmain3/
	ProxyPassReverse /subdomain3		https://192.168.1.4/subdmain3/

	#########################################################
	# SUBDOMAIN STUFF - END					#
	#########################################################

</VirtualHost>

<VirtualHost *:443>

        ProxyPass https://address.site2.com https://192.168.1.5/
        ProxyPassReverse https://address.site2.com https://192.168.1.5/

</VirtualHost>

Open in new window


So with the code above site 1, 2 and 3 all work just fine. The HTTPS redirects don't work though. Is there something obvious I'm missing?
0
Comment
Question by:NoOrdinaryRabbit
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 10

Accepted Solution

by:
asavah earned 500 total points
ID: 37737336
If you have several virtual sites on :80 port the SSL sites on :443 port wont't work because SSL sites require DEDICATED IP adress per site - http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html#vhosts
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Suggested Courses

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question