Solved

Using Apache2 to reroute 80 and 443 for various sites

Posted on 2012-03-18
1
574 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

706 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now