2

I just recently started to set up Apache on my Linux computer. I decided to use Virtual hosts because I want to run 2 web sites on the same machine. I set up both config files according to a tutorial I found. I did the following for both sites, where "mysite" is replaced by the domain name.

<VirtualHost *:80>
ServerAdmin admin@mysite.eu
ServerName mysite.eu
ServerAlias www.mysite.eu
DocumentRoot /var/www/mysite.eu/html
ErrorLog /var/www/mysite.eu/log/error.log
CustomLog /var/www/mysite.eu/log/access.log common
</VirtualHost>

My problem is, that when I run this and try to connect via the domain, I get the message "This site can't be reached". I enabled both config files, disabled the default config file and created the A record on my domain provider's page. What's weird, is that it works when I add 127.0.0.1 mysite.eu and 127.0.0.1 mysite2.eu in /etc/hosts. Any help regarding this issue would be appreciated. Edit: On the web site of my domain provider I have the option to specify a sub domain, the type of redirection, and the target. For the sub domain, I set up one redirection with "@" and one with "www". Both have the redirection type "A". They both point to my IP address "192.xxx.xxx.xx". I tried to do point both to my public IP address starting with 89 but this didn't work either, it still said "This site can't be reached."

  • I set this up about a week ago, but since I didn't work I changed it again and again. Seems like this could be the problem. To fix this should I just leave the server running for like 2 days and then try to access the site or do I just have to leave the DNS settings like it is? – reqqu87 Jan 9 at 6:06
2

They both point to my IP address "192.xxx.xxx.xx".

That is your problem. 192.168.x.x are defined as private local network IP addresses. That IP address is on a local LAN and hidden from the outside world by NAT. It is not going to be accessible from the outside world.

To make this work you need to use the external IP address of your server. If your server is not currently set up to be accessible to the outside world, you need to alter your network to make it so.

One way of doing that would be to use "port forwarding" on your router to forward requests on port 80 and 443. Requests that come in externally to your router need to get forwarded to your server. Then you would use your router's external IP address in your A records in DNS.

| improve this answer | |
  • "That is your problem. 192.168.x.x are defined as private local network IP addresses" - Although this would still work for all devices on the local network. I do wonder what the OPs motivation is... is this for local development? Or do they really want to serve websites publicly from their local server, together with all the caveats that this potentially entails? I do a similar thing and set a subdomain A record to my local webserver's internal (192.168.x.x) IP address - for local development (negates the need to use the HOSTS file on each machine, which for some devices is impossible). – MrWhite Jan 9 at 16:04

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.