You are not logged in.

#1 2014-03-24 21:39:49

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 787

trying to configure an apache vhost with the network hostname

I have an apache server running on my local network server and I can access it from another computer in a browser using the server's ip.  I also, however, want to be able to access it by it's hostname: noa

I assumed this required a vhosts setup so I uncommented the required Include line in httpd.conf and edited httpd-vhosts.conf to the following:

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost noa:80

<VirtualHost noa:80>
    ServerAdmin phunnilemur@gmail.com
    DocumentRoot "/srv/http"
    ServerName noa
    ErrorLog "/var/log/httpd/error_log"
    CustomLog "/var/log/httpd/access_log" common
</VirtualHost>

For some reason I get an "Access Denied"  error.  As I say, it works perfectly well if I use the ip to access the server rather than the hostname.

Offline

#2 2014-03-25 07:15:27

Gcool
Member
Registered: 2011-08-16
Posts: 1,456

Re: trying to configure an apache vhost with the network hostname

The machine you're browsing from will need to be able to resolve the name "noa" to the ip of your webserver somehow.

So you'll either need to run a dns server in your network (overkill if it's just for this one host), or simply add an entry to the client machine's hosts file for example.


Burninate!

Offline

#3 2014-03-25 11:47:11

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 787

Re: trying to configure an apache vhost with the network hostname

It already can.  I can ping the server using the name "noa" - and I can access the glassfish server running on the server using the name "noa".  Just not my apache server...

Offline

#4 2014-03-25 11:55:33

mzneverdies
Member
Registered: 2012-02-04
Posts: 147

Re: trying to configure an apache vhost with the network hostname

I think you must add an entry to your /etc/hosts file, as follows:

127.0.0.1       noa            noa

and create a vhost entry on /etc/httpd/conf/extra/httpd-vhosts

<VirtualHost *:80>
    ServerName noa
    DocumentRoot "/srv/http/"
    <Directory "/src/http/">
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

Although I'm not sure if the vhost is actually necesary, but it won't harm.

pd: if you use vhosts, remember to uncomment "Include conf/extra/httpd-vhosts.conf" con /etc/httpd/conf/httpd.conf and restart apache

# systemctl restart httpd

Offline

#5 2014-03-25 12:00:30

phunni
Member
From: Bristol, UK
Registered: 2003-08-13
Posts: 787

Re: trying to configure an apache vhost with the network hostname

Thanks for the reply - tried it, but it didn't work. Still same error: "Access Denied.", while going via the ip works.

Offline

Board footer

Powered by FluxBB