Liferay Dan Apache Mod_Proxy

jika anda menginstall liferay namun juga sudah punya web server seperti apache, maka anda dapat menghubungkan apache tersebut dengan liferay. Pada tutorial ini kebutuhan yang perlu disiapkan adalah :

  1. apache 2.2
  2. Liferay v 6.1 (tomcat)
  3. apache mod_proxy

langkah – langkah nya adalah sebagai berikut :

Edit httpd.conf atau sejenisnya

pada tutorial ini saya menggunakan linux opensuse 11.0, dan untuk konfigurasi apache nya berada di /etc/apache/defaultServer.conf

pada konfigurasi, tambahkan alias menggunakan mod_proxy seperti :

ProxyPass /liferay
ProxyPassReverse /liferay

pada perintah tersebut, kita akan membuat alias url /liferay untuk diteruskan ke yang mana itu merupakan alamat dan port dari liferay anda (asumsi anda tidak mengubah liferay port , dan anda menginstall liferay di satu server dangan apache).

jangan lupa restart atau reload apache anda

Tambahkan dan Edit

selanjutnya kita akan mengedit konfigurasi di sisi liferay, dengan tahapan sebagai berikut :

  1. masuk ke dalam direktori liferay
  2. masuk lagi ke dalam direktori tomcat
  3. masuk ke direktori webapss
  4. masuk ke direktori ROOT
  5. masuk ke direktori WEB-INF
  6. masuk ke direktori classes
  7. buat file baru (jika belum ada) dengan nama
  8. lalu edit file dan isikan portal.proxy.path=/liferay
  9. save dan exit
  10. restart tomcat



sekarang anda dapat mengakses liferay bukan dari http://ip-anda:8080/ , namun bisa dari http://ip-anda/liferay

happy coding all

Configure Apache To Serve Any Ruby Erb File (Like a mod_ruby or mod_erb) « I Am James’ Blog

Over the years there have been lots of cries for a mod_ruby on Apache that allowed users to ftp upload single ruby files to anywhere on their website and have Apache interpret the files and serve the resulting html, just like you can do with php files.  Granted, there has been a project called mod_ruby, but that project has long been unmaintained and plagued with issues.  Whether or not it is a good idea to copy the php method of writing webpages gets discussed at length every other week, so I will not get in to that here.

As it turns out, it’s pretty easy to configure Apache to do this, thanks to cgi and mod_actions.  This guide will show you how to configure Apache, so you can upload any erb file to anywhere on your Apache website and serve it up like a php file.  These erb files are html files embedded with ruby script inside special tags, just like php files are html files with php script embedded in them.

Install Apache

For this I’m using Ubuntu 10.04, the latest LTS release of Ubuntu.  There should be little or no difference doing this on Debian or other versions of Ubuntu.

sudo aptitude install apache2

Install Ruby

You’ll need ruby and an eruby library.  We’re keeping things simple and just installing what is in apt.

sudo aptitude install ruby1.9.1 liberubis-ruby1.9.1

Configure Apache

You just need ScriptAlias, AddHandler, and Action directives to tie everything together.  They can go anywhere in your Apache config files, but here is how I do it.

First, you need to enable the Apache Actions modules.

sudo a2enmod actions

Then put this in /etc/apache2/conf.d/erb-cgi

        AddHandler application/x-httpd-erb .erb        Action application/x-httpd-erb /cgi-bin/erb-cgi.rb

In the default site configuration under /etc/apache2/sites-available/default there is already a ScriptAlias directive, so I just left it there.  Here it is in case you don’t have it in your site config.

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

Now restart apache.

sudo service apache2 restart

The CGI Script

We’ve configured Apache so anytime a file ending with “.erb” is requested, Apache instead executes the erb-cgi.rb script and displays the output.  Lets write this script so it processes and outputs the requested file.

Put the following in /usr/lib/cgi-bin/erb-cgi.rb

#!/usr/bin/env rubyrequire 'erubis'puts "Content-type: text/htmln"# Check that the script is being executed through a redirectif ENV["REQUEST_URI"] =~ /^#{ENV["SCRIPT_NAME"]}.*/  puts "Script can not be executed directly!"else  # Get the file location from the ENV hash, read it, and process it through erubis  puts["PATH_TRANSLATED"])).result(binding())end

Make sure the file is executable by Apache.

sudo chgrp www-data /usr/lib/cgi-bin/erb-cgi.rbsudo chmod ug x /usr/lib/cgi-bin/erb-cgi.rb

Try It Out

You are now ready to upload erb embedded html files to anywhere under the DocumentRoot of your website.  This will handle any file with a .erb extension, however I prefer to use a .html.erb extension to differentiate these from other filetypes embedded with erb, such as .xml.erb.  Note:  this will actually handle erb embedded xml files, but you will have to modify the cgi script to check the file extension and change the content type.

Here is a quick example of an erb embedded html file.  Assuming you are using Ubuntu’s default site with the default DocumentRoot, save this in /var/www/test.html.erb

Hello !  The time is now .

You should now be able to open a browser  and go to http://your_server/test.html.erb and see the results.  You can now upload and serve erb files just like php files!

Feel free to ask any questions or make any suggestions in the comments!

Sources And More Information

For high traffic sites, using fastcgi (fcgid) instead of cgi would eventually become a necessity.  I don’t plan on using this for anything that gets much traffic, though, so I’m not exploring the configuration for fastcgi at the moment.  I also don’t know how this will handle form data through a POST request.  Also keep in mind that this will not allow you upload a Rails application and have it just work through this cgi script. It would probably be pretty easy to modify this to use rack, but running a full Rails app through cgi is a pretty bad idea, and should probably just be done with mod_passenger.

Advertisement –>

Like this:

Be the first to like this post.

HTTP Auth with mod_auth_imap – /me on the net!

Posted by Anurag inutilities
Tuesday, July 3. 2007

HTTP based authentication is the most common and easy-to-setup way of protecting content in apache. But with normal .htaccess/.htpasswd based protection, the problem is, .htpasswd file should be present in the webserver’s filesystem, and in most cases those users are not local unix users.

mod_auth_imap attempts to overcome this limitation by allowing apache to authenticate against an IMAP server, local/remote/whatever. Setting up authentication with mod_auth_imap is also straightforward.

  • Download the mod_auth_imap tarball from, and extract the contents.
  • Make sure apxs is installed (its available in apache2-dev package in debian)
  • Run # apxs -i -a -c mod_auth_imap.c as root user to build the apache module and install it in apache.
  • Make sure that mod_auth_imap module is enabled in your apache configuration.

An example .htaccess file will look like this.

#Turn on IMAP Authentication
Auth_IMAP_Enabled on
AuthName "Use IMAP username to login"
AuthType Basic

# Turn off Basic auth. We'll make IMAP as authoritative.
AuthBasicAuthoritative Off

#If you feel like it, restrict the users or allow all valid users:
# Require user foouser
Require valid-user

#Make IMAP Authentication authoritative for this .htaccess file:
Auth_IMAP_Authoritative on
Auth_IMAP_Port 143
Auth_IMAP_Log on