Debian – Varnish redirects to apache backend port 8000

.htaccessapache-2.2debianredirectvarnish

I set up an apache and a varnish on a dedicated server, which runs on debian squeeze.

Sometimes the varnish redirects to the apache backend port 8000. In this case the browser show i.e. mydomain.com:8000/shop/ and has no connection to the server and no content will be displayed.
I guess the problem is caused by my apache or varnish configs, which are both are very basic.

The varnish runs on port 80
The apache runs on port 8000

Here some examples:

mydomain.com/shop/ -> mydomain.com/shop/ (works! The shop is displayed correctly)

mydomain.com/shop -> mydomain.com:8000/shop/ (no connection to server;no content)

mydomain.com/phpinfo.php -> mydomain.com/phpinfo.php (works!)

The shop, which I am using, is shopware. I thought about editing the .htaccess in den shop directory, but that didn't work. So I am using the standard shopware .htaccess.

If it helps, I can post my config files (varnish/apache) or the correct url of my server.

I would be very thankful for any advice. I running out of ideas.

Thank in advanced!
Michael

Best Answer

This is a problem from Apache. Apache tries to canonicalize Urls.

The Url "http://example.com/foo" is different from "http://example.com/foo/" (with trailing slash). Still most of the time the same resource is desired.

Apache tries to rewrite the urls without trailing slash so they point to the urls with trailing slash.

Now there the probleme is that you have your server running on port 8000 so apache adds this too.

There are two options from my perspective:

  1. Run the Apache on port 80
  2. Set "UseCanonicalName Off" in your apache conf and build an own rewrite to point the Urls without trailing slash to the right point.