Overview
Sites/Organizations Site
Virtual Hosting is an extension of the friendly URL functionality of
Liferay that allows one or more SITES in a single portal instance to be
identified by separate and unique HOST NAMES (DNS entries).
End users type in the
name of the host they want to visit into the address bar in browser, and while
it APPEARS to the users that they are visiting different web sites, they are in
fact being directed to a Single Liferay Server. The Liferay server determines
which site to present to the user based on the URL.
Site Virtual Hosting Setup
Step – 1: Host Entries
The first step in
using a virtual host to ensure a Domain Name Server (DNS) entry exists for each
virtual host you want, and that every one of them point to the IP address of
Liferay server.
For testing we can
set up test DNS entries on a local machine that maps a host name to the IP
address of 127.0.0.1 by editing the hosts
file.
On Unix/Linux/Ubuntu
machine HOST file exist in “/etc/hosts”
And
On Windows machine HOST file exist in “\windows\system32\drivers\etc”
Step – 2: Liferay Settings
As Administrator, log
into Liferay portal instance. Ensure you have access to the "Sites".
Go to the Control Panel and Select the site to map the virtual host name. Click on the “Site Setting” section and then
click on the “Site URL” link on the Site Setting page.
On the “Site URL” page,
each Site has a “Friendly URL” and “Virtual Hosts” section. Under the “Virtual
Hosts” section "Public Pages" and “Private Pages" URL area exist
to have their own virtual host name.
Note: Virtual hosts
names are optional. You can specify a name for the public pages site only, the
private pages site only, or both.
Now in the “Virtual
Host” section, configure the Public Pages site URL:
For example
www.siteone.com (in my case I am using www.starcj.com)
For example if
Friendly URL as /siteone, this means instead of typing the URL
“http://localhost:8080/web/siteone” we can map this entire URL with
the "www.siteone.com"
(in my case I am
using www.starcj.com).
That’s it the Liferay
setting is over.
In Browser
Type the URL as http://www.siteone.com:8080
Note: We have to type
the port number along with the URL , which will take us to the desired site
means:
http://localhost:8080/web/siteone
to http://www.siteone.com:8080
In my case it is
http://localhost:8080/web/starcj to http://www.starcj.com:8080
http://localhost:8080/web/starcj to http://www.starcj.com:8080
Remove the Port number from the URL
Approach 1: Using mod_jk Module with Apache
With the help of
mod_jk module with Apache, we can easily access site url without Port number
http://www.siteone.com:8080 to http://www.siteone.com
Install Apache Web
Server (if already not exist)
Install and configure
mod_jk module (if already not exist/configured)
Once Apache,
Mod_jk installation/configuration done, we need to configure the URL Apache
should pass through the Tomcat in “/etc/apache2/sites-enabled/000-default”
and add the following line
<VirtualHost *:80>..............................................................................JkMount /* ajp13_worker</VirtualHost *:80>
Note: In
my example I am referring the defult “workers.properties” file of mod_jk for
Apache.
/etc/libapache2-mod-jk/workers.properties
# Define 1 real worker using ajp13worker.list=worker1# Set properties for worker (ajp13)worker.ajp13_worker.type=ajp13worker.ajp13_worker.host=localhostworker.ajp13_worker.port=8009
Now restart the
servers (Apache as well as Tomcat Liferay Server)
Approach 2: Changing the Liferay Tomcat Server Port 8080 to 80
Whenever you enter a
URL without a port, it defaults to port 80, the standard http port. Change the
Tomcat's listening port from 8080 to 80, and you'll be done.
Step:
1.) Locate server.xml in {Liferay Tomcat installation folder}\ conf \2.) Find following similar statement
<Connector port="8080" maxHttpHeaderSize="8192"maxThreads="150" minSpareThreads="25" maxSpareThreads="75"enableLookups="false" redirectPort="8443" acceptCount="100"connectionTimeout="20000" disableUploadTimeout="true" />
or
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000" redirectPort="8443" />
3.) About Tomcat’s server.xml file cites it’s
runs on port 8080. Change the Connector
port=”8080″ port to any other port number.
For example
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
Above statement instruct Tomcat
server runs on port 80.
4.) Edit and save the server.xml file. Restart Tomcat. Done
4.) Edit and save the server.xml file. Restart Tomcat. Done
Finally access the http://www.siteone.com URL in browser
without port. Liferay site - siteone landing page will open
successfully. In my case it is http://www.starcj.com