Solved

Using Apache2 to reroute 80 and 443 for various sites

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

Title # Comments Views Activity
Only allow one site in Internet Explorer on XenApp. 9 50
Which Linux flavors will this run on? 6 76
AWS vpc peering connection 1 42
PHP_POST() error message 9 41
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
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…

911 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

21 Experts available now in Live!

Get 1:1 Help Now