Solved

Using Apache2 to reroute 80 and 443 for various sites

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

In Solr 4.0 it is possible to atomically (or partially) update individual fields in a document. This article will show the operations possible for atomic updating as well as setting up your Solr instance to be able to perform the actions. One major …
Fine Tune your automatic Updates for Ubuntu / Debian
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

813 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

17 Experts available now in Live!

Get 1:1 Help Now