apache2 won't show virtual hosts to outside requests

Problems with the Linux version of XAMPP, questions, comments, and anything related.

apache2 won't show virtual hosts to outside requests

Postby jonas-e » 24. February 2015 09:46

I installed apache2 on this host called NAS2 and set up a few virtual hosts, they're running fine. So, I decided to access them from another computer (laptop) on the network. First, I added NAS2 to the host file of my laptop, still no luck:
Code: Select all
10.0.0.3 prod.wp.ellevator.net


No big surprise there. I opened up my ufw firewall on NAS2 to incoming requests on port 80:
Code: Select all
ufw status
Status: active

To                         Action      From
--                         ------      ----
137,138/udp                ALLOW       Anywhere
139,445/tcp                ALLOW       Anywhere
80                         ALLOW       Anywhere
137,138/udp (v6)           ALLOW       Anywhere (v6)
139,445/tcp (v6)           ALLOW       Anywhere (v6)
80 (v6)                    ALLOW       Anywhere (v6)


After that my laptop can access the apache server on NAS2, great - it shows the apache welcome page when I navigate to http://nas2. However, it doesn't show the site associated with other http headers - the http://wp.prod.ellevator.net that I put in the host file on my laptop still returns the default welcome page from apache. On NAS2 however, it works fine - apache delivers the virtuals hosts that I request through my browser.

I tried adding "Allow from all" to apache2.conf:
Code: Select all
<Directory /mnt/jbod_01/jonas/sites/ellevator.net/apache/>
   Options Indexes FollowSymLinks
   #AllowOverride None
   AllowOverride all
   Allow from all
   Require all granted
</Directory>


And to my virtual host config file:
Code: Select all
<VirtualHost *:80>
   DocumentRoot /mnt/jbod_01/jonas/sites/ellevator.net/apache/prod.wp.ellevator.local
   ServerName prod.wp.ellevator.local
   #ServerAlias prod.wp.ellevator.local
   <Directory /mnt/jbod_01/jonas/sites/ellevator.net/apache/prod.wp.ellevator.local>
      Options FollowSymLinks
      Allow from all
      AllowOverride All
   </Directory>
</VirtualHost>


I restarted the apache2 service, but still no luck accessing those sites from the laptop.

Any idea what is wrong?


Details about the NAS2 host LM17.1 mate 64bit:
Code: Select all
inxi -Fxz
System:    Host: nas2 Kernel: 3.13.0-24-generic x86_64 (64 bit, gcc: 4.8.2) Desktop: N/A Distro: Linux Mint 17.1 Rebecca
Machine:   Mobo: MSI model: FM2-A55M-E33 (MS-7721) version: 2.0 Bios: American Megatrends version: V10.4 date: 01/15/2013
CPU:       Dual core AMD A4-5300 APU with Radeon HD Graphics (-MCP-) cache: 2048 KB flags: (lm nx sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm) bmips: 13574.3
           Clock Speeds: 1: 1400.00 MHz 2: 1400.00 MHz
Graphics:  Card: Advanced Micro Devices [AMD/ATI] Trinity [Radeon HD 7480D] bus-ID: 00:01.0
           X.org: 1.15.1 drivers: ati,fglrx (unloaded: fbdev,vesa,radeon) tty size: 125x38 Advanced Data: N/A for root
Audio:     Card-1: Advanced Micro Devices [AMD] FCH Azalia Controller driver: snd_hda_intel bus-ID: 00:14.2
           Card-2: Advanced Micro Devices [AMD/ATI] Trinity HDMI Audio Controller driver: snd_hda_intel bus-ID: 00:01.1
           Sound: Advanced Linux Sound Architecture ver: k3.13.0-24-generic
Network:   Card: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller
           driver: r8169 ver: 2.3LK-NAPI port: e000 bus-ID: 01:00.0
           IF: eth0 state: up speed: 100 Mbps duplex: full mac: <filter>
Drives:    HDD Total Size: 2064.4GB (1.7% used) 1: id: /dev/sda model: SPCC_Solid_State size: 64.0GB
           2: id: /dev/sdb model: SAMSUNG_HD103SJ size: 1000.2GB 3: id: /dev/sdc model: SAMSUNG_HD103SJ size: 1000.2GB
Partition: ID: / size: 52G used: 34G (69%) fs: ext4 ID: swap-1 size: 8.00GB used: 1.69GB (21%) fs: swap
           ID: swap-2 size: 0.53GB used: 0.00GB (0%) fs: swap
RAID:      Device-1: /dev/md0 - active components: sdc2[0] sdb2[1]
           Info: raid: N/A report: N/A blocks: 1952491776 chunk size: N/A
Sensors:   None detected - is lm-sensors installed and configured?
Info:      Processes: 309 Uptime: 13 days Memory: 5822.8/7371.4MB Runlevel: 2 Gcc sys: 4.8.2 Client: Shell inxi: 1.8.4
jonas-e
 
Posts: 9
Joined: 23. July 2010 15:01

Re: apache2 won't show virtual hosts to outside requests

Postby jonas-e » 24. February 2015 09:46

Keeps getting weirder! Now these two virtual hosts work from my laptop - "site1.local" in /var/www/html/site1.local and "ellevator.net" in /mnt/jbod_01/jonas/sites/ellevator.net/apache/ - but not the other virtual hosts (eg "prod.wp.ellevator.local") configured exactly the same way.

apache2.conf:
Code: Select all
# Default setting
<Directory /var/www/>
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
   Allow from all
</Directory>
# By me
<Directory /mnt/jbod_01/jonas/sites/ellevator.net/apache/>
   Options Indexes FollowSymLinks
   #AllowOverride None
   AllowOverride all
   Allow from all
   Require all granted
</Directory>
<Directory /mnt/jbod_01/jonas/sites/ellevator.net/apache/prod.wp.ellevator.local>
   Options Indexes FollowSymLinks
   Allow from all
   AllowOverride All
   Require all granted
</Directory>


And site-available/000-default.conf
Code: Select all
<VirtualHost *:80>
   DocumentRoot /var/www/html/site1.local
   ServerName www.site1.local
   ServerAlias site1.local
</VirtualHost>
<VirtualHost *:80>
   DocumentRoot /mnt/jbod_01/jonas/sites/ellevator.net/apache
   ServerName www.ellevator.local
   ServerAlias ellevator.local
</VirtualHost>
<VirtualHost *:80>
   DocumentRoot /mnt/jbod_01/jonas/sites/ellevator.net/apache/prod.wp.ellevator.local
   ServerName prod.wp.ellevator.local
</VirtualHost>


That's either inconsistent or I am overlooking something?
jonas-e
 
Posts: 9
Joined: 23. July 2010 15:01

Re: apache2 won't show virtual hosts to outside requests

Postby Nobbie » 24. February 2015 13:53

Which Apache Release (precisely)?

Where is the NameVirtualHost Definition?
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: apache2 won't show virtual hosts to outside requests

Postby jonas-e » 25. February 2015 13:42

Thanks Nobbie

Code: Select all
Server version: Apache/2.4.7 (Ubuntu)
Server built:   Jul 22 2014 14:36:38


What do you mean by NameVirtualHost?

Apache is installed in /etc/apache2, location of configuration file is /etc/apache2/apache2.conf.

The virtual hosts are defined in directory /etc/apache2/sites-available - probably defined by these lines:
Code: Select all
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf


I added all my virtual hosts to the existing file:
/etc/apache2/sites-available/000-default.conf
But I could probably put them in separate files in the same directory as long as they fit *.conf pattern.
jonas-e
 
Posts: 9
Joined: 23. July 2010 15:01

Re: apache2 won't show virtual hosts to outside requests

Postby Nobbie » 25. February 2015 15:59

jonas-e wrote:What do you mean by NameVirtualHost?


This was a required declaration prior to Apache 2.4, see http://httpd.apache.org/docs/2.2/en/mod ... irtualhost



jonas-e wrote:The virtual hosts are defined in directory /etc/apache2/sites-available - probably defined by these lines:
Code: Select all
# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf


I added all my virtual hosts to the existing file:
/etc/apache2/sites-available/000-default.conf


Seems that you used the wrong directory, the virtual hosts configurations are searched in "sites-enabled" (see above!), but you put them into "sites-available". Unknown VirtualHosts are always resolved by the FIRST known VirtualHost directive.
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: apache2 won't show virtual hosts to outside requests

Postby jonas-e » 26. February 2015 22:29

Seems I was a bit confused there, I now compared the two files with the program Meld
/etc/apache2/sites-available/000-default.conf
/etc/apache2/sites-enabled/000-default.conf

They are completely identical. I guess apache must have taken content from one and written in to the other. I don't suppose that resolves anything ...
jonas-e
 
Posts: 9
Joined: 23. July 2010 15:01


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 4 guests