1

Using examples from DigitalOcean, Rackspace and others, I have (repeatedly) setup a server to provide name-based Vhosts. I have several domains registered and forwarded to my current public IP address, but any attempt to access any of them via the web results in only the default host of last resort responding.

I added the server's public IP address and the domain names to another local computer OS's hosts file, and all websites appear to be functioning fine via local access.

Since this is my first stab at web hosting, I am limited in knowing what to try next. It seems that since LAN access functions OK (with the server info added to the hosts file) and from www the server is found and requests are processed, the settings are at least close to correct. I'm thinking there's a .conf file or some such that just isn't quite right. Or perhaps router port forwarding?

Any suggestions? Any code snippets I should add here to help clarify?


Update. Here is my Virtual Host .conf file:

# domain: example.com 
# public: /var/www/example.com/html 
<VirtualHost *:80> 
    ServerAdmin admin@example.com
    ServerName example.com 
    ServerAlias www.example.com 
    DocumentRoot /var/www/example.com/html 
    LogLevel debug ErrorLog /var/log/apache2/error-mydomainname.com.log 
    CustomLog /var/log/apache2/access-mydomainname.com.log combined 
</VirtualHost>
  • Could you show us your Virtual Host .conf file? It must be in /etc/apache2/sites-enabled/. And yes you need to do port forwarding from your router (that has a public IP) to the server in your LAN (that has only local IP). The ports for HTTP/HTTPS are 80 and 443. Please read this answer and especially the last section (Nr.6). – pa4080 Mar 24 '18 at 12:17
  • @pa4080 Thanks for offering ideas... content of my .conf in site-enabled: – Steve124 Mar 25 '18 at 12:50
  • # domain: example.com # public: /var/www/example.com/html <VirtualHost *:80> ServerAdmin admin@example.com ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/example.com/html LogLevel debug ErrorLog /var/log/apache2/error-mydomainname.com.log CustomLog /var/log/apache2/access-mydomainname.com.log combined </VirtualHost> – Steve124 Mar 25 '18 at 12:51
  • The router port forwarding seems to be OK, as accesses resolve at least to the default... BTW, apologies for format of these notes. I'll endeavor to learn hoe to copy/paste here. – Steve124 Mar 25 '18 at 12:56
  • You can use the edit button under the question/answer to make changes/updates inside. – pa4080 Mar 25 '18 at 12:59
1

After changes be sure to restart your apache2 server. Your router also needs to allow access to the ports on your computer. You can pretty much follow the guides on the VPS type servers. They are the same for a local hosting computer.

  • Thanks Jack. Ufw status reports inactive... I take that as a bad thing, am checking into the links you provided. – Steve124 Mar 23 '18 at 0:53
  • All files are present in sites-enabled - local access couldn't work without them being there. Router is letting www accesses in - they just are not resulting in successful access, hence the default site responses. – Steve124 Mar 23 '18 at 0:56
  • It is activated by ufw enable. Activate it and check status. If your ports are not open you will probably want to use the command ufw allow 80/tcp Then restart your apache2 server. – JackNorthrup Mar 23 '18 at 0:57
  • Enabled ufw, allowed http/https/80/tcp. No improvement – Steve124 Mar 23 '18 at 1:08
  • You can use this URL to see if your port is open canyouseeme.org – JackNorthrup Mar 23 '18 at 1:14
1

Problem is resolved. Solution was to properly configure the DNS records for the sites with my registrar. I had not set the IP address for the A record in the proper field - the manager's menu allowed for two different ways to do this, and I had not picked the correct method.

Thanks to @JackNorthrup and @pa4080 for their kind assistance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.