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>
pa4080
  • 29,831
SteveMc
  • 21
  • 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: – SteveMc 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

    – SteveMc 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. – SteveMc 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
  • @pa4080 Content of ports.conf: – SteveMc Mar 25 '18 at 13:01
  • NameVirtualHost *:80 Listen 80 Listen 443 – SteveMc Mar 25 '18 at 13:02
  • Steve124, what happens when you try to open http://<your-router-public-ip>/ in the browser? – pa4080 Mar 25 '18 at 13:03
  • And perhaps a bit of explanation as to why my Enter keystroke is sending my comments instead of doing a cr/lf in the comment? – SteveMc Mar 25 '18 at 13:04
  • pa4080 If the default sites-enabled/.conf is present I see its webpage. If I clear that from the dirctory, I see the Not Found response that bogus URLs result in – SteveMc Mar 25 '18 at 13:06
  • Please check this answer. (There is not new lines within the comments, so pressing of the Enter key just publish them.) – pa4080 Mar 25 '18 at 13:07
  • Whois resolves OK – SteveMc Mar 25 '18 at 13:10

2 Answers2

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. – SteveMc Mar 23 '18 at 00: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. – SteveMc Mar 23 '18 at 00: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 00:57
  • Enabled ufw, allowed http/https/80/tcp. No improvement – SteveMc Mar 23 '18 at 01:08
  • You can use this URL to see if your port is open http://canyouseeme.org/ – JackNorthrup Mar 23 '18 at 01: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!

SteveMc
  • 21