Monday, November 24, 2008

Reverse proxying with Apache 2.2

Hi:

Sometimes you need to have Apache work as a reverse proxy, for example, to expose a web server behind a firewall to the public internet, or to add SSL. This is my short example on how to do it for the SSL case, but the other one should be similar.

<virtualhost 172.16.4.179:443>
        # Define location of SSl certificates and turn SSL On.
        SSLEngine on
        SSLOptions +StrictRequire
        SSLCertificateFile /etc/ssl/certs/server.crt
        SSLCertificateKeyFile /etc/ssl/private/server.key
        # Set up reverse proxy
        ProxyRequests Off
        
                Order deny,allow
                Allow from all
        
        # Expose /ESAL with contents of http://localhost:8080/ESAL
        ProxyPass /ESAL http://localhost:8080/ESAL
        ProxyPassReverse /ESAL http://localhost:8080/ESAL
        # Expose /limesurvey with contents of http://localhost/~eortega/limesurvey
        ProxyPass /limesurvey http://localhost/~eortega/limesurvey
        ProxyPassReverse /limesurvey http://localhost/~eortega/limesurvey

</virtualhost>

Here we are exposing through SSL sites that are published on non SSL locations (http://localhost:8080/ESAL/ and http://localhost/~eortega/limesurvey/).



Sunday, November 23, 2008

Using IEXPRESS to create installers

Hi:

Say you have a program with one or more files that you need to pack as in an installer. IEXPRESS allows you to pack them up easily, and define the way to install them. So you can give the user a single executable file that, when clicked on, will extract all packaged files to a temporary location and run an installation command (EXE, BAT or INF file defining installation parameters).

In order to open IEXPRESS, go to windows start menu, select run. On the dialog box type "iexpress" and hit enter. This will load a wizard that will help you build the pack file. Choose "Create new self extraction directive", hit next. Next select whether you want installation to be automatically started after extraction of files from your package, just extract  or something about activeX we don't care about. Choose "Extract and run" and hit next.  You are prompted for a name for the package. Type in the name that best suits your needs and hit next. Next you are given the choice to let the user that will run extraction be asked (or not) if he wants to install the package after files are extracted. If you say yes, you have to enter a prompt message that will be shown to the user. Click next. You are given the choice to add a license file to your package. If you add one, it will be shown to the user performing the installation. Hit next. Here comes the good part. Press Add button and browse and select all files you want to package. Choose as many as you need. Don't forget to pick the one you want to run right after extraction. Hit next. You are asked to select one of the files from the package to be run as installation command. This should be EXE, BAT or INF (other executables may work, but I have not tested them. For details on how to write INF files that define installations read my related post). Pick your installation file and, optionally, another file to be run AFTER installation has finished. Hit next. Then you are given the choice to show (minimized or maximized) or hide the installation program window. Pick your choice and hit next. Now you can optionally enter a message that will be displayed to the user after installation. Hit next. Now select an output file (the file that you will give the user to run).  Enter a name and hit next. I am pretty sure you can figure out next steps.

So anyway, you en dup with a single EXE file that, when run, extracts all files you chose to package and runs installation command as you specified. Have fun!

Writing simple INF files for installation of software with IEXPRESS

Hi, all:

I have been working on a small project that requires a simple installer. The installer is expected to:
  1. Copy a few files to a location where they can be accessed later, is not too visible, and where the user running the installation process has write access.
  2. Add a registry key
So here is how the INF looks:

[version]
signature="$CHICAGO$"

[DefaultInstall]
CopyFiles = copy.files
AddReg=Add.Settings

[copy.files]
program.exe

[Add.Settings]
HKCU,Software\Microsoft\Windows\CurrentVersion\run\,program,0x00000000,"%16410%\program.exe"

[DestinationDirs]
copy.files = 16410

[SourceDisksNames]
81=,"",1


Brief explanation follows:
  • [version]: just put it there, needed for the INF to work. No particular meaning.
  • [DefaultInstall]: what will be done when the install takes place. In this case, we tell Windows Installer to copy files as specified on [copy.files] and add registry keys as specified on [Add.Settings].
  • [copy.files]: list of files to be copied. One file per line.
  • [Add.Settings]: nasty syntax. HKCU means Registry key HKEY_CURRENT_USER. Next (after first comma) is the registry subkey. Next is the entry name. Next is the registry type of value. Finally, the value itself. So this would produce a REG_SZ entry called program inside HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\run\ with value "c:\documents and settings\username\application data\program.exe". Note that %16410% is expanded to the "Application Data" directory of the user running setup. More on this below. More on Registry manipulation through inf files here.
  • [DestinationDirs]: this tells Windows Installer to cpy files listed on section [copy.files] to directory with ID equal to 16410. Windows XP has a number of directories which are identified by numeric IDs. These IDs are called DIRIDs (original, uh?). 16410 is the DIRID for "Application Data" directory of the user running the setup. Notice that, when used for adding the registry key above, we had to surround it with % symbol, so that it is expanded to a directory instead us using it as a directory called 16410. Full list of DIRIDs is available here.
  • [SourceDisksNames]: this one tells Windows where are the source files. 81 is just some ID for the dir, pick any number you want. Just make sure that if you have several lines on this section, the IDs are different for each one. Next is a description of the disk (empty in our case). Next comes an optional CAB file which has the files (also empty in our case). Next is 1, which is unused on modern Windows versions. More details on this entry can be found here.
Check out my post on using IEXPRESS with this INF file to create an installer.