0

I am in the process of hosting two separate domain names on their own Raspberry Pi 3: https://www.iwasframed.com and https://www.findyourchild.org using Google Domains & their Dynamic DNS API. These are my A records and AAAA records for iwasframed.com. And these are my A and AAA records for findyourchild.org.

My hardware includes:

  1. Two Raspberry Pi 3 Model B
  2. One AT&T U-verse Pace 5268AC Gateway Internet Wireless Modem Router

cat /proc/device-tree/model:

Raspberry Pi 3 Model B Rev 1.2

cat /etc/os-release:

PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
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"

apache2 -v:

Server version: Apache/2.4.52 (Raspbian)
Server built:   2022-01-03T21:27:14

mysql -V:

mysql  Ver 15.1 Distrib 10.5.12-MariaDB, for debian-linux-gnueabihf (armv7l) using  EditLine wrapper

ip a && ip r:

(iwasframed.com):

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:82:72:4d brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:d7:27:18 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.76/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0
       valid_lft 70852sec preferred_lft 60052sec
    inet6 2600:1700:3b01:2a70:b648:20cf:994:626/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 3599sec preferred_lft 3599sec
    inet6 fe80::cdc9:5bc:9b4e:7f4b/64 scope link
       valid_lft forever preferred_lft forever
default via 192.168.1.254 dev wlan0 proto dhcp src 192.168.1.76 metric 303
192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.76 metric 303

(findyourchild.org):

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:3f:84:2e brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:6a:d1:7b brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.80/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0
       valid_lft 78792sec preferred_lft 67992sec
    inet6 2600:1700:3b01:2a70:bffc:91d3:e3f7:9f3a/64 scope global dynamic mngtmpaddr noprefixroute
       valid_lft 3555sec preferred_lft 3555sec
    inet6 fe80::4915:c978:283e:7c4a/64 scope link
       valid_lft forever preferred_lft forever
default via 192.168.1.254 dev wlan0 proto dhcp src 192.168.1.80 metric 303
192.168.1.0/24 dev wlan0 proto dhcp scope link src 192.168.1.80 metric 303

sudo nano /etc/resolv.conf:

(iwasframed.com) & (findyourchild.org):

# Generated by resolvconf
domain attlocal.net
nameserver 192.168.1.254
nameserver 2600:1700:3b01:2a70::1

000-default.conf:

(iwasframed.com):

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.iwasframed.com [OR]
RewriteCond %{SERVER_NAME} =iwasframed.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

000-default.conf:

(findyourchild.org):

<VirtualHost *:80>

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

The problem I'm running into is that I have no issues setting up my first Raspberry Pi and domain, https://www.iwasframed.com, however, when I try to setup my second Raspberry Pi with domain, https://www.findyourchild.org, by opening up port 80 and 443, then the router throws an error:

HTTP conflicts with Web Server which is currently in use on iwasframed.com. HTTP and Web Server use the same resources and cannot both be hosted at the same time. To use HTTP, you must first remove Web Server from the application list of iwasframed.com. Alternatively, you can install the applications on one computer and add both application profiles to the application list for that computer.

Secondly, because they have the same public IP, then https://wwww.findyourchild.org is pointing towards https://www.iwasframed.com: ---- Check-Your-Website

Could someone provide some guidance if it's possible to open ports 80 & 443 for my second Raspberry Pi on the same network, using the same router & public IP? Or should I just be using one Raspberry Pi to host both domain names?

2
  • You can't map the same external "socket" (IP:port) to multiple internal sockets, at least not statically, since that's logically/mathematically impossible.
    – Tom Yan
    Commented Mar 14, 2022 at 21:17
  • Assuming you want the second Raspberry Pi to handle the second site for hardware reasons, instead of hosting both sites on one Raspberry Pi, Apache can be set up as a reverse proxy for the second site. The first Pi would still handle all incoming requests for both domains but forward requests for the second site to the second Pi for it to handle. Commented Mar 14, 2022 at 22:18

1 Answer 1

0

The easiest solution is hosting both domains as virtual sites in the same RPi/Apache.

Each site will have it own config file in Apache declaring the domain in ServerName and the corresponding pages directory in DocumentRoot as follows:

/etc/apache/sites-available/iwasframed.conf:

<Virtual Host *:80>
    ServerName www.iwasframed.com
    DocumentRoot /var/www/html/iwasframed
    RedirectMatch /(.*)$ https://www.iwasframed.com/$1
      :
</VirtualHost>

<Virtual Host *:443>
    ServerName www.iwasframed.com
    DocumentRoot /var/www/html/iwasframed
      :
</VirtualHost>

/etc/apache/sites-available/findyourchild.conf:

<Virtual Host *:80>
    ServerName www.findyourchild.org
    DocumentRoot /var/www/html/findyourchild
    RedirectMatch /(.*)$ https://www.findyourchild.org/$1
      :
</VirtualHost>

<Virtual Host *:443>
    ServerName www.findyourchild.org
    DocumentRoot /var/www/html/findyourchild
      :
</VirtualHost>

Note I prefer using mod_redirect to handle forcing HTTP to HTTPS. Also, the port 443 sections must have the relevant SSL configuration directives.

To enable the sites, use the a2ensite command to create links to the config files in sites-available to sites-enabled (omit the file extensions):

sudo a2ensite iwasframed findyourchild

and restart/reload Apache.

Reference: Apache2.4 Name-based Virtual Host Support

Additional info: If the sites will have many simultaneous connections, consider using the Apache mpm_event module instead of the default mpm_prefork.

Edit: Other solution can be having a third RPi at the front with the described virtual sites' configuration where each one redirects to the real RPis hosting the sites' data (Could be used if a single RPi cannot have both web trees because of disk space, ports or external drives limitations).

You must log in to answer this question.

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