0

I trying to set up a local webserver on a Raspberry. I get the LAMP installation up and running, the hosts and vhosts are ok when I open pages directly on the server, but all incoming traffic from other device on the network goes to the "other_vhosts_access.log".

What I did

On my computer, the /etc/hosts file contains the line to redirect www.webfantasy.test to the server:

192.168.1.78 www.webfantasy.test

On the server, the /etc/hosts file contains the line to redicrect www.webfantasy.test to localhost (needed, the vhost wasn't loaded is I didn't add it):

127.0.1.1 www.webfantasy.test

The 000-default.conf has been remove from sites-enabled using the commands "a2dissite" and apache service has been reload.

The specific domain vhost file is activated:

<VirtualHost www.webfantasy.test:80>
    ServerName www.webfantasy.test
    ServerAlias www.webfantasy.test

    DocumentRoot /var/www/webfantasy
    DirectoryIndex index.php

    LogLevel warn
    ErrorLog ${APACHE_LOG_DIR}/webfantasy_error.log
    CustomLog ${APACHE_LOG_DIR}/webfantasy_access.log combined
</VirtualHost>
apache2ctl -t -D DUMP_VHOSTS
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
127.0.1.1:80           www.webfantasy.test (/etc/apache2/sites-enabled/webfantasy.conf:1)

What I get

  • From the server, the www.webfantasy.test answers with the correct page ( /var/www/webfantasy/index.php) and is logged in the webfantasy_access.log file
  • From my computer, the www.webfantasy.test answers with the default Debian/Apache page ( var/www/html/index.html ) and is logged in the other_vhosts_access.log file

Did someone knows what I could modify in order for to work properly?

1
  • Have you tried to see what your computer thinks the address should be? Does nslookup www.webfantasy.test return 192.168.1.78?
    – tsc_chazz
    Commented Nov 23 at 19:15

1 Answer 1

1

Have you read the documentation? It says this:

You may replace * with a specific IP address on the system. Such virtual hosts will only be used for HTTP requests received on connection to the specified IP address.

<VirtualHost www.webfantasy.test:80> binds the vhost to www.webfantasy.test, which resolves to 127.0.1.1 - or localhost. It will only ever work on localhost; any request on any other interface will not go to this vhost.

Remove the entry in the servers /etc/hosts, and use <VirtualHost *:80>, like the documentation suggests.

2
  • Thanks, I did indeed misunderstand the use of the different VirtualHost parameters. It is clearer after your answer and after rereading these pages of the documentation. And it works fine now! Commented Nov 24 at 8:36
  • Apache has excellent documentation. Start with the examples, and only modify what you have to.
    – vidarlo
    Commented Nov 24 at 10:02

You must log in to answer this question.

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