Problem with lshttp and Apache Reverse Proxy

Discussion in 'Install/Configuration' started by hofred929, May 19, 2008.

  1. hofred929

    hofred929 New Member

    Hi,
    I have configured litespeed 3.3.11 with php4 4.4.8 (recompiled) on an internal Linux RHEL4-U2 box and the Horde/IMP mail application worked fine.
    However, when I try to access the domain via the external IP address serviced by the Apache with Reverse Proxy, I got error 404:
    404 Not Found
    The resource requested could not be found on this server!

    Note that in the test I have shutdown the internal Apache webserver on port 80 and activated LiteSpeed on port 80.

    Looking at the Virtual host domain log, the only message was:
    202.64.220.xx - - [19/May/2008:00:12:48 +0800] "GET / HTTP/1.1" 404 390 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12"

    The lsws VHOST configuration is:
    <?xml version="1.0" encoding="UTF-8"?>
    <virtualHostConfig>
    <docRoot>$SERVER_ROOT/MyWWW/html/horde-312</docRoot>
    <enableGzip>1</enableGzip>
    <enableIpGeo>0</enableIpGeo>
    <logging>
    <log>
    <useServer>0</useServer>
    <fileName>$VH_ROOT/logs/error.log</fileName>
    <logLevel>DEBUG</logLevel>
    <rollingSize>5M</rollingSize>
    </log>
    <accessLog>
    <useServer>0</useServer>
    <fileName>$VH_ROOT/logs/access.log</fileName>
    <pipedLogger></pipedLogger>
    <logFormat></logFormat>
    <logHeaders>7</logHeaders>
    <rollingSize>5M</rollingSize>
    <keepDays>30</keepDays>
    <bytesLog></bytesLog>
    <compressArchive>1</compressArchive>
    </accessLog>
    </logging>
    <index>
    <useServer>0</useServer>
    <indexFiles></indexFiles>
    <autoIndex>0</autoIndex>
    <autoIndexURI></autoIndexURI>
    </index>
    <scriptHandlerList>
    <scriptHandler>
    <suffix>php</suffix>
    <type>lsapi</type>
    <handler>phpLsapi</handler>
    <note></note>
    </scriptHandler>
    </scriptHandlerList>
    <htAccess>
    <allowOverride>15</allowOverride>
    <accessFileName>.htaccess</accessFileName>
    </htAccess>
    <expires>
    <enableExpires>1</enableExpires>
    <expiresDefault>A4800</expiresDefault>
    <expiresByType></expiresByType>
    </expires>
    <security>
    <hotlinkCtrl>
    <enableHotlinkCtrl>0</enableHotlinkCtrl>
    <suffixes>jpeg, png, jpg, gif</suffixes>
    <redirectUri></redirectUri>
    <allowDirectAccess>1</allowDirectAccess>
    <onlySelf>1</onlySelf>
    <allowedHosts></allowedHosts>
    <matchedHosts></matchedHosts>
    </hotlinkCtrl>
    </security>
    </virtualHostConfig>

    The external Apache (outside the Firewall) configure is:
    <VirtualHost 202.64.220.xx:80>
    ServerName mail.fredho.net
    LogLevel warn
    ErrorLog logs/error.log
    TransferLog logs/access.log
    <IfModule mod_proxy.c>
    ProxyPass / http://192.168.1.215/
    ProxyPassReverse / http://192.168.1.215/
    </IfModule>
    </VirtualHost>

    There're no errors on the external Apache log in reviewing any problem on the proxy.

    Note also that I am not enable Apache config in the lsws setup.

    Any ideas what I did wrong in the setup for Reverse Proxy?
    Thanks.
  2. mistwang

    mistwang LiteSpeed Staff

  3. hofred929

    hofred929 New Member

    Hi, the listener is set to *:80 for all IP addresses on the machine already. I have other VHOSTs defined on this machine as well, all on port 80 but using different IP addresses.

    I can access the web sites okay within the 192.168.1 network. The only problem is through the external IPs proxy, it failed with 404 errors. The trouble is I couldn't find any error messages on Apache nor LSWS telling me exactly what's wrong. Stopping LSWS and restarted Apache on the host the web sites can be access with no problem via the proxy.

    Attached is the httpd_config.xml.

    Please help.
    Thanks.

    Attached Files:

  4. mistwang

    mistwang LiteSpeed Staff

    Code:
        <listener>
          <name>MAILX2</name>
          <address>*:80</address>
          <secure>0</secure>
          <note></note>
          <vhostMapList>
            <vhostMap>
              <vhost>FREDHO</vhost>
              <domain>mail.fredho.net</domain>
            </vhostMap>
            <vhostMap>
              <vhost>CITYUP</vhost>
              <domain>mail.city-up.com</domain>
            </vhostMap>
            <vhostMap>
              <vhost>BUHRD</vhost>
              <domain>mail.buhrd.com</domain>
            </vhostMap>
          </vhostMapList>
        </listener>
    
    add "192.168.1.215" to the "domain" section of the vhost associated with that IP.
  5. hofred929

    hofred929 New Member

    Hi,
    So the <domain> part is actually an IP address, it won't do a DNS lookup?
  6. hofred929

    hofred929 New Member

    Thanks. By changing the domain name to IP address 192.168.1.215 it fixed the problem and Apache reverse proxy worked. But then, the URL showed http://192.168.1.215/... instead of http://mail.fredho.net/... as in Apache.
    Is there anyway to use the domain name in the URL instead of the internal IP which will failed outside the firewall?

    Apache has the UseCanonicalName setting which will set the IP address to the ServerName as specified in the httpd.conf. How can LSWS miminc this?

    PS. I have an internal DNS which will resolve the domain to the internal IP address if inside the internal network, and to the external IP when outside the Firewall through the ISP's DNS.

    Fred
  7. mistwang

    mistwang LiteSpeed Staff

    You can use both

    <domain>mail.fredho.net,192.168.1.215</domain>
  8. hofred929

    hofred929 New Member

    Hi,
    It worked the URL page showed domain name mail.fredho.net.
    But the PHP application Horde/IMP makes use of the PHP _SERVER[] array settings and I found that LSWS did not set the variable _SERVER['SERVER_NAME'] to the domain name but the IP address instead. The Horde PHP application will redirect the URL using the PHP system variable _SERVER['SERVER_NAME'] and rendered the web page failure.

    I am including the phpinfo() output on "PHP Variables" from the Apache (4311phpinfo.html) and from the LSWS (448phpinfo.html) for your information. Is there anyway to set the SERVER_NAME to mail.fredho.net in LSWS?

    Fred

    Attached Files:

  9. mistwang

    mistwang LiteSpeed Staff

    Try "ProxyPreserveHost" directive if you use Apache 2.x
  10. hofred929

    hofred929 New Member

    That fix it. Many Thanks.

    As a side question, does LSWS support Reverse Proxy? If so, how do I configure it?
  11. mistwang

    mistwang LiteSpeed Staff

Share This Page