0

Problem: I have set up my first Apache 2 web server to host my personal website and Nextcloud. It's running on a Raspberry Pi and through various guides and videos I have managed to make the website and cloud available from outside my own network. However, when I try to access it from any device on the same IP as the web server, it doesn't work. Of course, using my local ip to access the site and cloud do work (though images on the website don't work because these are linked to my domain).

Research:I have not bee able to get any use out of previous similar posts, most of which don't have concrete answers either. From what I can gather there are several things that could be an issue here: config files (hosts, ports, apache2 etc.), my custom ClouDNS setup, my DHCP/static IP setup, or some setting in the router.

My setup:

  1. Pi has static local IP
  2. ClouDNS provides the link between my domain and the public IP of my home network
  3. I have exactly followed this (Instructable link) tutorial with the exception of installing the RAID, which is irrelevant
  4. I initially installed No-IP and used it, but I don't any longer. It's still installed on the Pi though, not sure if that matters.
  5. Despite the manual editing of the SSL encryption via the Instructable, I did edit and run the DietPi-Letsencrypt service. again, not sure if it matters.
  6. Ports 443 and 80 are properly forwarded in the router and I am running DHCP for my network with the exception of the Pi, which has a locked IP. I also set up the static IP including public DNS in the Dietpi-Config. Some issue there?
  7. The one thing I am puzzled about is the part in the Instructable where I comment out all of /etc/apache2/sites-available/000-default.conf and add the forced https. However, after this process at some point the file added or uncommented ServerName MYDOMAIN.COM, which I have once again commented out, not that it makes a difference either way.

I am all new to Apache, the Pi and the whole shabang, but any help would be much appreciated. I want to very much stress this whole questions is about curiosity and a more elegant solution as I technically can access everything from within my own network, just not using the domain I assigned to the server.

Thanks so much for any advice!

3
  • So, just to clarify, you cannot reach the web page from inside your network when you attempt to connect via your public IP address?
    – Sam Forbis
    Commented Aug 19, 2020 at 20:39
  • Sorry, I can reach web page and Nextcloud from my own network if I type in my public IP (again, except for the images on webpage). But I cannot access via my domain. Commented Aug 19, 2020 at 20:50
  • For further info on the setup on ClouDNS: master/host is MYDOMAIN.COM, I have kept the nameservers as provided by ClouDNS (not sure what to do with them), but I have added an A record to have MYDOMAIN.COM point to MYPUBLICIP. There's also a CNAME to redirect www.MYDOMAIN.COM to MYDOMAIN.COM. I assume somewhere on ClouDNS or in one of my config files, something doesn't let my devices with my PUBLICIP access my very own server via the corresponding MYDOMAIN. Commented Aug 19, 2020 at 20:57

1 Answer 1

0

I am not certain if this will resolve your issue, but a couple things to consider:

  • In /etc/apache2/sites-available/000-default.conf perhaps try this instead:

      <VirtualHost *:80>
    
          # As a general rule, the ServerName should
          # not be commented out in a virtual host.
    
          ServerName example.com
    
          # To have this host respond to e.g. www.example.com 
          # (not just example.com), a ServerAlias directive
          # needs to be included as well.
    
          ServerAlias www.example.com
    
          ServerAdmin [email protected]
    
          # For simple redirects, using Redirect is 
          # preferable to mod_rewrite, per the official
          # Apache 2.4 documentation.
    
          Redirect permanent / https://example.com/
    
      </VirtualHost>
    
  • Your SSL virtual host should also have a ServerName and ServerAlias:

      <VirtualHost *:443>
    
          # As a general rule, the ServerName should
          # not be commented out in a virtual host.
    
          ServerName example.com
    
          # To have this host respond to e.g. www.example.com 
          # (not just example.com), a ServerAlias directive
          # needs to be included as well.
    
          ServerAlias www.example.com
    
          ServerAdmin [email protected]
    
          # SSL and Nextcould configuration stuff goes here.
    
      </VirtualHost>
    
  • Rather than using a CNAME for www.example.com, simply create a normal A record for the subdomain and give it the same IP as example.com.

2
  • Should example.com be replaced by your public domain name? For example if I have duckdns redirected to this apache server, should i replace example.com occurences by mycustomdomain.duckdns.org?
    – RabidTunes
    Commented May 3, 2021 at 12:29
  • If you want to try and access your Apache server via e.g. mycustomdomain.duckdns.org, then yes, that should replace example.com above. The value after the ServerName directive is the exact string Apache uses to match connections to a given virtual host. Note that you likely don't need the ServerAlias directive(s) unless you want to specify more than one domain name for the same host (so adding e.g. www.mycustomdomain.duckdns.org isn't useful unless that domain really exists in DNS). Commented May 3, 2021 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .