0

Here is basically what I would like to do:

  • http request comes in, portforwarding in router sends it to a server in the local network (server A)
  • the server identifies the request for a virtual host
  • server a has a rewrite rule for that virtual host which rewrites the request to send it to server B, which is on the same local network
  • Server B gets the request, identifies a virtual host and sets the document root according to the virtual host setting

It works until server B, the request always ends up in the default definition. Is this possible at all? I'm running Debian Wheezy.

Server A apache config file /etc/apache/sites-enabled/wiki

<Directory /var/lib/shared/websites/wiki/www>
    Options None
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>

    ServerName wiki
    ServerAlias wiki.asus.local
    ServerAlias wiki.mydomain.net
    DocumentRoot /var/lib/shared/websites/wiki/www
    CustomLog /var/lib/shared/websites/wiki/log/access.log combined
    ErrorLog /var/lib/shared/websites/wiki/log/error.log

    RewriteEngine on
    RewriteRule ^/(.*) http://192.168.10.91/$1 [P,L]

</VirtualHost>

Server B apache config file /etc/apache/sites-enabled/wiki

<Directory /var/lib/shared/websites/wiki/www>
    Options None
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>

    ServerName wiki
    ServerAlias wiki.mydomain.net
    DocumentRoot /var/lib/shared/websites/wiki/www
    CustomLog /var/lib/shared/websites/wiki/log/access.log combined
    ErrorLog /var/lib/shared/websites/wiki/log/error.log

</VirtualHost>

Oh and also Server B is complaining apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName on restarting apache, this has probably something to do with that, but the usual answer on that just adding ServerName localhost to the apache.conf can't be right in this case, all my other servers are missing the definition in the apache.conf and none of them complains ever.

Anyone got any idea on this? Is this even possible, what I wanna do? (rewriting a virtual host and then putting request in virtual host again)

Thanks for any help!

1 Answer 1

1

I think your problem is RewriteRule ^/(.*) http://192.168.10.91/$1 [P,L]. If you access to your second server with the IP, virtualhost is not going to work. You can try to set a specific domain name to your server B and replace the ip with it in the rewriterule

1
  • thanks mate, so simple, makes sense! just added 192.168.10.91 wiki.mydomain.net to the /etc/hosts file on server A and all works.
    – Preexo
    Jan 9, 2015 at 9:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .