I self host two websites on a Apache2 instance that runs on a Raspberry Pi3 (more info on versions and configurations below): Website1 is a a static website that I coded from scratch, while website2 runs on Wordpress.
I used to live in an apartment where the ISP provided a static public IP but I recently moved to a new house, where the ISP does not provide that option. I have been trying to reconfigure everything but I cannot make it all work again.
Configurations
I have a Raspberry Pi 3 running the latest version of Raspbian
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
VERSION_CODENAME=stretch
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
On my router (model: Alcatel-Lucent G240W-B
) I have opened port XX for http and port YY for ssh (I am not using standard ports to increase security)
Application Name | WAN Connection | WAN Port | LAN Port | Internal Client | Protocol | Status
Customer settings | {my_wan_connection} | XX~XX | XX~XX | 192.168.1.100 | TCPorUDP | ACTIVE
Customer settings | {my_wan_connection} | YY~YY | YY~YY | 192.168.1.100 | TCPorUDP | ACTIVE
I am running apache2
$ apache2 -v
Server version: Apache/2.4.25 (Raspbian)
Server built: 2019-08-19T19:25:31
with two websites enabled
$ sudo apache2ctl -S
VirtualHost configuration:
*:XX is a NameVirtualHost
default server mydomain.ddns.net (/etc/apache2/sites-enabled/website1.com.conf:1)
port XX namevhost mydomain.ddns.net (/etc/apache2/sites-enabled/website1.com.conf:1)
alias website1.com
alias www.website1.com
port XX namevhost mydomain.ddns.net (/etc/apache2/sites-enabled/website2.com.conf:1)
alias www.wesbiste2.com
alias wesbiste2.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: MODSEC_2.5
Define: MODSEC_2.9
User: name="www-data" id=33
Group: name="www-data" id=33
Also, this is my ports.conf
$ sudo cat ports.conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf
Listen 0.0.0.0:XX
<IfModule ssl_module>
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I have set a dynamic DNS with NoIP (mydomain.ddns.net) which gets updated through my router
What works and what does not
SSH works fine, and I can connect to my raspberry pi both within my home network and from outside - when I check if door YY is open from a port checking tool I get a positive response
HTTP is more problematic: despite the door being closed (according to port checkers at least) I can see website1 (which is apache's default server) from
- internal ip address: 192.168.1.100:XX
- public ip address: {my-public-ip}:XX
- dynamic dns hostname mydomain.ddns.net
However, since in this ways I can only access website1, and not website2, I tried to disable website1 (sudo a2dissite website1.com.conf
) and restart apache (sudo systemctl restart apache2
)
$ sudo apache2ctl -S
VirtualHost configuration:
*:XX mydomain.ddns.net (/etc/apache2/sites-enabled/website2.com.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: MODSEC_2.5
Define: MODSEC_2.9
User: name="www-data" id=33
Group: name="www-data" id=33
However, I still cannot access website2 from internal or public ip, nor DDNS hostname.
Changing Wordpress URL
I thought this might be related to Wordpress and indeed I found this article and followed the instructions to [change the URL directly in the database][2]. Indeed the 'home' and 'url' values were equal to my old public static IP so I changed the to my DDNS (myhostname.ddns.net). However, the site is still unaccessible
FYI, my first priority would to be able to access website2 and see its contents, whether through internal or external IP, or DDNS hostnmae.