Showing posts with label Web Server. Show all posts
Showing posts with label Web Server. Show all posts

Saturday, January 07, 2012

Using Apache HTTPD (Web Server) mod_proxy with GlassFish and Mercurial

I wrote an article on how to use Secure Mercurial in GlassFish using SSL a few weeks ago. After the article was published, I was asked about URL rewriting. I had not really messed with it in the past except with PrettyFaces (which works like a champ for reference).

I tried a framework called Url Rewrite Filter which did a decent job of rewriting URLs. It is a simple library added to your project which uses a servlet filter to handle the URL re-writing. Add the filter to the web.xml, and a urlrewrite.xml which handles the rewrites. It works much in the same manner as PrettyFaces, but is targeted at JSP/Servlets.

In my case, I have an Apple G5 PPC which is the main server for my source repository for Mercurial. This presents some challenges since the Java version is limited to 1.5, and therefore GlassFish can't be upgraded to v3 from v2.1.1. I did manage to get GlassFish v3 to run with OpenJDK 1.7 (BSD Port), but the Zero VM is too slow to handle the load. Kurt Miller has a couple of the builds for Mac PPC There are a number of reasons for my interest, the primary one for URL rewriting is that GlassFish v3 supports AJP out of the box.

Enabling JK Listener (mod_jk)

Using GlassFish v3 would provide a more optimal solution as you can see from the administration console. I decided to try using the mod_jk articles I found for GlassFish v2 from Amy Roh: GlassFish supports configurable AJP Connector and Jean-Francois Arcand's Running GlassFish with Apache httpd.  I tried to combine these with mod_proxy and mod_proxy_ajp. The articles are focused on a specific build, and I was unsuccessful in using them. I am sure it has to framework versions, but I did not want spend too much time troubleshooting.

Finally, I tried using a simple mod_proxy arrangement along with mod_rewrite. This arrangement was surprisingly easy to configure, and worked the first time I tried it.

Here is the configuration I used:

httpd.conf



httpd-vhosts.conf


Those simple changes allowed me to rewrite the URL, and open only two ports on my firewall 80 and 443 which are a very good arrangement. As noted in Secure Mercurial in GlassFish using SSL, I am using GlassFish SSL and security to handle my authentication so this is truly a very good solution.
Mercurial Repositories

Thursday, July 08, 2010

Mac OS X Leopard/Snow Leopard Web Sharing Forbidden Issues

Forbidden
You don't have permission to access /~username/ on this server.

Have you received an error like the one above, then I may have the solution for you. There are a number of posts on the web around permissions, and Apache configuration files, etc. I found that the solution was really simple, yet not obvious.

It has to do with File Sharing, you need to add the Sites directory to the list of directories which are shared, even if sharing is not turned on. See the example below.


Once you add the Sites directory to the list and turn on Web Sharing, you should be able to see the local sites for users on the local system.

Monday, June 16, 2008

Configuring Apache 2 HTTP Server on Solaris 10

How do you configure Apache 2 HTTP Server to run automatically on Solaris 10 using rc init scripts.

Log into the Solaris box as root, or su root.
Go to the /etc/init.d directory.
Copy the apache startup script to apache2
cp apache apache2

Change the group to sys
chgrp sys apache2
Next change the flags on the file to execute
chmod u+x apache2
Open the apache2 file with your favorite editor and modify the following lines:

APACHE_HOME=/usr/apache
CONF_FILE=/etc/apache/httpd.conf
RUNDIR=/var/run/apache
PIDFILE=${RUNDIR}/httpd.pid

as follows:

APACHE_HOME=/usr/apache2
CONF_FILE=/etc/apache2/httpd.conf
RUNDIR=/var/run/apache2
PIDFILE=${RUNDIR}/httpd.pid

Check to make sure you have a valid httpd.conf file located in /etc/apache2. You can copy the httpd.conf-example file to httpd.conf. This will create a basic httpd.conf file.

Next go to the /etc/init.d directory and try executing the apache2 file. You should see something like this:

[dev1:init.d:root]#./apache2 start
httpd starting.
You can check your configuration by using a browser to check it.

Next you will want to configure it to start/stop at the various runlevels.

Go to /etc/rc0.d and add the following:
ln -s ../init.d/apache2 K17apache2
Go to /etc/rc1.d and add the following:
ln -s ../init.d/apache2 K17apache2
Go to /etc/rc3.d and add the following:
ln -s ../init.d/apache2 S51apache2
Go to /etc/rcS.d and add the following:
ln -s ../init.d/apache2 K17apache2

This will complete the configuration for your server. Next time you change run levels, or reboot, the Apache 2 HTTP Server will restart as you expect.

Addendum:

Zaphod commented on my page about using Solaris SMF. This is truly easier.

1. Check to make sure you have a valid httpd.conf file located in /etc/apache2. You can copy the httpd.conf-example file to httpd.conf. This will create a basic httpd.conf file.

2. Execute svcadm -v enable -rs apache2

3. You are now running on Apache2 on SMF.

Thursday, May 22, 2008

Using PHP Add-On (Plugin) on Sun Java System Web Server 7.0

Sun has a great product in its Web Server, but the PHP plugin (Web Server 7.0 PHP Add-On 1.0) is almost completely useless. It will do PHP perfectly well, but who simply uses just PHP.

There are a number of extensions that are available for PHP which are available. The plugin is a very vanilla compilation of PHP 5. Sun should have compiled the plugin with most, or all of the available extensions. This would have made the plugin a complete drop-in replacement for using PHP on Apache.

There is hope... The plugin is based on PHP 5.2.0. I have a simple set of instructions on how to use the binary from the PHP archive site for Windows to replace the missing functionality.

  1. Go to PHP Releases page and download the Windows binary.
  2. Unzip the binary files.
  3. Shutdown the Web Server administration site, and any instances.
  4. Go to the plugin directory and zip up the php plugin just in case... My directory is located in C:\Program Files\Sun\WebServer7\plugins.
  5. Copy the extensions directory from the unzipped files to the plugin directory.
  6. Copy the php.exe and php-cgi.exe to the plugin directory
  7. Copy the .dll files from the unzipped files in the root directory to the plugin directory.
  8. From a command line run php -v from the plugin directory. If it is missing any files that it needs, it should report them. Copy the missing files to the directory.
  9. Restart the instances and make sure the logs are clear.
The list below represents the .dll files which I have in my php plugin directory.
  • gds32.dll
  • libeay32.dll
  • libmcrypt.dll
  • libmhash.dll
  • libmysql.dll
  • libswish-e.dll
  • msql.dll
  • ntwdblib.dll
  • php5ts.dll
  • php_bz2.dll
  • php_curl.dll
  • php_dba.dll
  • php_dbase.dll
  • php_exif.dll
  • php_fdf.dll
  • php_gd2.dll
  • php_gettext.dll
  • php_gmp.dll
  • php_ifx.dll
  • php_imap.dll
  • php_interbase.dll
  • php_ldap.dll
  • php_mbstring.dll
  • php_mcrypt.dll
  • php_mhash.dll
  • php_mime_magic.dll
  • php_ming.dll
  • php_msql.dll
  • php_mssql.dll
  • php_mysql.dll
  • php_mysqli.dll
  • php_oci8.dll
  • php_openssl.dll
  • php_pdo.dll
  • php_pdo_firebird.dll
  • php_pdo_mssql.dll
  • php_pdo_mysql.dll
  • php_pdo_oci.dll
  • php_pdo_oci8.dll
  • php_pdo_odbc.dll
  • php_pdo_pgsql.dll
  • php_pdo_sqlite.dll
  • php_pgsql.dll
  • php_pspell.dll
  • php_shmop.dll
  • php_snmp.dll
  • php_soap.dll
  • php_sockets.dll
  • php_sqlite.dll
  • php_sybase_ct.dll
  • php_tidy.dll
  • php_xmlrpc.dll
  • php_xsl.dll
  • php_zip.dll
  • ssleay32.dll

Good luck and let me know how it works for you. I will see about posting an enhancement request to Sun to incorporate all of the extensions on version 2.0 of the add-on.

Popular Posts