How-to configure a Reverse Proxy with Apache2 for Windows

8,838

As John has alluded to, the default configuration for Apache installed on Windows is at Program Files\Apache2.2\httpd.conf in a flat file. The path may be somewhat different, as I don't have a Windows machine handy at the moment. Most Linux distributions have their own custom hierarchical structure which looks something like the following. This example is from Debian and may vary with other distributions.

  • /etc/apache2/
    • apache2.conf Package provided configuration
    • conf.d/
      • Individual configuration files, usually from other packages, but could also be local configuration files
    • httpd.conf Local configuration file. Overrides contents of apache2.conf
    • mods-available/
      • Individual module configuration files, provided by the package and any support packages
    • mods-enabled/
      • Links to files in mods-available. Links are created/removed with a2enmod and a2dismod. Creating a link enables the given module.
    • ports.conf Enabled ports
    • sites-available/
      • Individual VirtualHost-style configuration files
    • sites-enabled
      • Links to files in sites-available. Links are created/removed with a2ensite and a2dissite. Creating a link enables the given site.

I've described all this to hopefully make it easier to understand how to replicate it under Windows. With the exception that links are not well supported under Windows (has this changed in Vista/Server 2008/Windows 7?) it's relatively easy to set this structure up. But you will have to do it manually, since the default configuration doesn't do it for you. Make sure you adjust the following to match the Linux distribution you're migrating from.

  1. Assuming the original configuration file on Windows is at \Program Files\Apache2.2\httpd.conf (again, this may not be the correct location, I'll need to check a Windows machine to be sure), create the following directories:

    • \Program Files\Apache2.2\conf.d\
    • \Program Files\Apache2.2\sites-enabled\

    You don't need the sites-available directories since links aren't supported under Windows. You can add them if you want, but things won't work the same. Also, I'd recommend putting the module configurations into the httpd.conf file. Since they aren't managed by the package manager, it will be easier to just keep them in one spot.

  2. Make any modifications from the Linux httpd.conf file to the Windows file. If you have an apache2.conf file under Linux, this is easy, since httpd.conf will only have overrides for apache2.conf.

  3. Add a ports.conf file, if desired. The contents of this can also exist in the httpd.conf file.

  4. Copy files that exist in the Linux conf.d directory into the Windows directory. Make sure the filenames end with .conf, adding it if it wasn't there before. This is done to help make directory parsing (set up below) less error prone.

  5. Copy files that exist in the Linux sites-enabled directory into the Windows directory. As in step 4, make sure the filenames end with .conf, adding it if it didn't exist under Linux.

  6. Add the following to the end of the httpd.conf file:

    # If you added a ports.conf file, add the following
    Include ports.conf
    # Include the conf.d files
    Include conf.d/*.conf
    # Include the enabled sites
    Include sites-enabled/*.conf
    
  7. Restart Apache. Make sure you check for and correct any configuration errors.

This might not get you there 100%, but it should get you close.

Share:
8,838

Related videos on Youtube

Ice
Author by

Ice

I'm working as a consultant in a software company. Our developers are building a desktop-application on windows-platform using sql-server, exchange-server ... It's me who is talking to our customers to implement it on their systems.

Updated on September 17, 2022

Comments

  • Ice
    Ice over 1 year

    I got up and running a reverse proxy on apache2 under Linux (Ubuntu). Now i see that there is a different folder-structure under Windows. My linux-conf - files don't work under windows or am i wrong?

    Please show me the way

    • Ice
      Ice over 14 years
      Hi tinkertim, What Client configuration? i assumed the apache2 server-configuration under a windows2008-server which seems to be different to a linux-server. The Question has nothing to do with 'server' it's a issue of configuration and the difference between these two OS. Am i wrong?
    • Ice
      Ice over 14 years
      To be more precise: My linux configuration on 192.168.134.10 looks like that: /etc/apache2/sites-availbale/backuppc - this file holds the definition of a <VirtualHost *> To activate this i run: sudo a2ensite backuppc and sudo /etc/init.d/apache2 reload and everything is fine Apache under windows looks something different: - no folder sites-available - no folder sites-enabled and so on... Please show me the way, thx. Ice
  • Ice
    Ice over 14 years
    Hi John, i don't understand your question. I install apache 2 under linux and the folder struktur is given and so is it when i install a apache2 under windwos... The struktur is given in both cases and it is not the same? I don't have invented the folder-struktur wheter under linux nor under windows. This post is somewhat unpopular pushed from stackoverflow to serverfault - i could understand that... Please help.
  • John Gardeniers
    John Gardeniers over 14 years
    The folder structure you described is not standard under Windows. What's the problem? Just copy the structure, as I've already explained.
  • Ice
    Ice over 14 years
    This is an answer! thx Michael Johnson i soone will give it a try. you will get feedback. Ice
  • Ice
    Ice over 14 years
    Ok and you are shure that the apache service will find it's files?