2

I have been trying to set up my apache server for many days now, to no avail. I have acquired a DynDNS Pro account and have also registered a domain name with names.co.uk (I haven't even figured out what to do with that yet, and if I even need it at all).

I've configured my sites-enabled folder in the /etc/apache2 directory to point to the directory where I have my .html documents. It works fine when I have DynDNS set up to the local IP Address 192.168.x.x. But I know that this means that other people can't access my website. When I go to the DynDNS website and change the IP address to what is my public IP, if I try to access my website "shredalert.homelinux.com" it takes me to the login page for my router. I am completely boggled as to why this occurs. This is my first time trying to set up a web server and website. Please have some patience if I make really silly comments/assumptions.

I should add that I have already forwarded port 80 for 192.168.x.x. How would I fix my apache server to load my website, instead of loading my router login page when I change my IP to my public IP address on DynDNS?

P.S. Would very much appreciate if someone who uses "names.co.uk" could tell me how I could utilise the domain name I have registered.

shredalert
  • 169
  • 1
  • 1
  • 9

1 Answers1

3

A few notes :

  • your domain's configured dns servers must point to dyndns
  • your router must forward port 80 to your local machine. The ip address on your local machine should be static and ideally reserved on the router.
  • your machine must have port 80 open
  • if all this is setup correctly, if you do http://externalIp you should get your default apache page (same as http://localhost)
  • you must set a virtualhost for shredalert.homelinux.com to listen, or put that domain as alias of localhost with ServerAlias shredalert.homelinux.com directive on your main config file.

Create the virtualhost file /etc/apache2/sites-available/shredalert.homelinux.com.conf like :

<VirtualHost *:80>
    ServerName shredalert.homelinux.com
    DocumentRoot /path/to/root/directory
    ErrorLog "/var/log/apache2/error.shredalert.homelinux.com.log"
    CustomLog "/var/log/apache2/access.shredalert.homelinux.com.log" common

    <Directory /path/to/root/directory>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>
</VirtualHost>

Then enable the site and restart (or reload) apache2 service

sudo a2ensite shredalert.homelinux.com.conf
sudo service apache2 restart

Note : you can change /path/to/root/directory to anything you want, so not necessarily you must expose your complete localhost root dir.

bistoco
  • 1,511
  • 15
  • 22
  • I am aware of how to set a virtual host, but how do I put it to "listen" for shredalert.homelinux.com? I am not sure if my port is open or not. When I type in `netstat -ntlp | grep LISTEN` I get the following: tcp6 0 0 :::80 :::* LISTEN 6968/apache2 – shredalert Aug 01 '15 at 13:22
  • I reinstalled apache2 to try and configure it from a fresh start. Could you please supply instructions about how I should configure the apache2.conf file and the 000-default.config file in the /sites-enabled directory for my DNS host server shredalert.homelinux.com please? I can't seem to find any tutorials on how to configure apache v2.4 on the internet. All I keep finding are tutorials for how to configure v2.2, and the file structure is quite different. – shredalert Aug 01 '15 at 14:09
  • I have made a directory called `/srv/shredalert.homelinux.com` and put that as the `DocumentRoot`. I followed the steps that you have showed me. I made an html file called index.html in my root directory for the site. After following your steps and setting up a virtual host, it still logs me into my router instead of loading up my html document. No idea why this is happening. – shredalert Aug 02 '15 at 12:20
  • even if the apache config is wrong, it should not get the router page, are you sure you configured the router to forward port 80 to your machine? if so, since it's not working, maybe you have to reboot to apply changes. – bistoco Aug 02 '15 at 13:30
  • I have realised that I forgot to set up a static IP for my DynDNS. Now that I have set up a static IP 192.168.1.30 and forwarded port 80 on my router, it no longer tries to log me into my router. However, I have run into a new problem. When I try to load up my website, it says "This web page is not available." – shredalert Aug 02 '15 at 14:07
  • I restarted my pc, and it seems to work for me now. When I got my friend to try to visit the website it says "This web page is not available". – shredalert Aug 02 '15 at 14:12
  • It turns out that my router was blocking my ports. I have managed to solve my problem with your help. I express my deepest gratitude to you good sir! – shredalert Aug 04 '15 at 01:41
  • I do have one more question though. Since my website has started to work, whenever I try to access it from my internal network it opens up my router page instead of the website. The website does work fine externally. Is this normal behaviour? – shredalert Aug 04 '15 at 02:39
  • It's not, i have a similar (not with dyndns) setup and if i access both by ip and domain, it redirects to my local apache. The difference is that ip goes to localhost and domain goes to the specific virtualhost. – bistoco Aug 04 '15 at 02:43
  • Any idea on what might be causing this problem? – shredalert Aug 04 '15 at 02:48
  • A long shot, on my router setup i had disabled remote web management, that's the only thing i can think of now. – bistoco Aug 04 '15 at 02:58
  • Turning off remote management for my LAN led to me not being able to access my router by any means. So I had to reset the router. It seems that the DNS is the main problem. When I set the IPV4 address in the DNS config to 192.168.1.x it just works fine internally, but externally it doesn't. When I change it to my public IP address, it makes me load my router page when I try to access the webpage from within my network, but it works fine when I connect to it using my phone's 3G. – shredalert Aug 04 '15 at 03:08
  • even with remote management disabled, you should be able to acecss your router web interface on 192.168.1.1 or whatever local ip your router get. – bistoco Aug 04 '15 at 03:12