logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Need Help getting Subdomains to work off one Apache instance
Author
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Fri 21 Apr '23 19:52    Post subject: Need Help getting Subdomains to work off one Apache instance Reply with quote

I have followed several "How To" and my subdowmian just does not work.

Install Ubuntu (latest)
Install apache2
Install PHP 8

Create two dirs for the subdomains
md /var/www/S1
echo Hello this is Site 1 > /var/www/S1/index.html
md /var/www/S2
echo Hello this is Site 2 > /var/www/S2/index.html

/etc/apache2/sites-available.s1.conf
Code:
<VirtualHost *:80>
        ServerName s1.disorbo.us
        ServerAlias  dd.disorbo.us

        DocumentRoot /var/www/S1

    <Directory /var/www/S1>
        AllowOverride All
        Options -Indexes
        Require all granted
    </Directory>

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


/etc/apache2/sites-available.s2.conf
Code:
<VirtualHost *:80>
        ServerName s2.disorbo.us
        ServerAlias  ld.disorbo.us

        DocumentRoot /var/www/S2

    <Directory /var/www/s2.DiSorbo.US>
        AllowOverride All
        Options -Indexes
        Require all granted
    </Directory>

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


a2ensite s1.conf
a2ensite s2.conf
systemctl reload apache2

Add DNS to point to my NAtted router and I never see site 2 just site 1

Did I miss something ?
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 333
Location: UK

PostPosted: Mon 24 Apr '23 20:41    Post subject: Reply with quote

You don't say which HowTo you followed, but on Ubuntu, you should place your additional Apache configuration files in directory /etc/apache2/sites-available, viz:
    /etc/apache2/sites-available/s1.conf
    /etc/apache2/sites-available/s2.conf
Then enable these extra configuration files with symbolic links in /etc/apache2/sites-enabled, viz:
Code:
# cd /etc/apache2/sites-enabled
# ln -s ../sites-available/s1.conf
# ln -s ../sites-available/s2.conf

Check the configuration, and if all is well then restart Apache:

Code:
# apachectl -S
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost 127.0.1.1 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost s1.disorbo.us (/etc/apache2/sites-enabled/s1.conf:1)
                 alias dd.disorbo.us
         port 80 namevhost s2.disorbo.us (/etc/apache2/sites-enabled/s2.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33

# systemctl restart apache2

You might also want to consider having separate log files for each site.
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Mon 24 Apr '23 23:47    Post subject: Reply with quote

Wait one sec are you saying that the file name in sites-available must match the domain name so if I have a DNS entries for s1.mydomain.com and s2.mydomain.com then the conf files are to be called s1.conf and s2.conf - What if I named then Site1.mydomain.com.conf sithtwo.mydomain.com.conf that makes it not work?? cuz that's the only disconnect I see. I can email the exact steps I took if that helps but I didn't want to post it all here (but I will if I have to)
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 333
Location: UK

PostPosted: Tue 25 Apr '23 17:21    Post subject: Reply with quote

I don't believe I said the name of the configuration file must match the domain name; indeed the filename can be whatever you like, providing it has a .conf extension, and lives in the sites-available directory.

In your original post you listed the files as /etc/apache2/sites-available.s1.conf rather than /etc/apache2/sites-available/s1.conf.

I presume this was a typo, otherwise your a2ensite commands would have failed with a "ERROR: Site xxx does not exist!" message.

Does the "apachectl -S" command show your virtual host configurations correctly, as per my post?

If not, you've a mistake in your configuration setup, else you've a network/routing problem to track down.

If you do need to post (anonymized) configuration details, logs, etc. then use https://apaste.info, and reference the URL in this thread.
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Tue 25 Apr '23 17:37    Post subject: Reply with quote

Yes it was a typo. apachectl -S shows correct

Do I have to enable a MOD or change some apache2.conf file to actually turn this on or enable virtual hosts of the listener ?????

Code:
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server s1.mydomain.com (/etc/apache2/sites-enabled/domenic.mydomain.com.conf:18)
         port 80 namevhost s1.mydomain.com (/etc/apache2/sites-enabled/domenic.mydomain.com.conf:18)
                 alias domenic.mydomain.com
         port 80 namevhost s2.mydomain.com (/etc/apache2/sites-enabled/leo.mydomain.com.conf:18)
                 alias leo.mydomain.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: 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
User: name="www-data" id=33
Group: name="www-data" id=33
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Tue 25 Apr '23 18:47    Post subject: Reply with quote

tangent wrote:

If not, you've a mistake in your configuration setup, else you've a network/routing problem to track down.

If you do need to post (anonymized) configuration details, logs, etc. then use https://apaste.info, and reference the URL in this thread.


On the actual apache server I added the site name and the ip of the server so 192.168.1.20 s1.mydomain.com and s2.mydomain.com to the hosts file

If I wget s1.mydomain.com and wget s2.mydomain.com the results are infact the two different subdomains but this does not work once you move off the serer

my router sends port 80 to 192.168.1.20 plus when on the same subnet one ip away the router should not come into play well actually it does do DNS but its showing my default apache page so its gotta be redirecting
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Tue 25 Apr '23 19:39    Post subject: Reply with quote

OK so it seems that this is definitely NAT or Router related

I have a old ubuntu destop that I fired up. I added the server ip 192.168.1.20 to that box's hosts files for both s1.mydoamin.com and s2.mydomain.com and it works

Quote:
Sooooo I think this may be a network issue or a router issue

Now how do I fix this. DNS is is done on GoDaddy through I use a rinker script to find & update my public ip on GoDaddy with an A record pointing to my public IP. Then I set up forwarders for the subdomain and point them to that domain in the A record
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 333
Location: UK

PostPosted: Tue 25 Apr '23 23:23    Post subject: Reply with quote

Based on your original post, you listed disorbo.us, which I assume is your domain root.

If I lookup disorbo.us viz: https://www.whatsmydns.net/dns-lookup?query=disorbo.us&server=cloudflare

I get an A record of 68.227.209.56, with no authority (SOA) listed, and so presume that's your public IP.
There are no AAAA records present, but that does list the SOA as disorbo.us.

Whois confirms this DNS record is managed through GoDaddy.

However, if I lookup s1.disorbo.us https://www.whatsmydns.net/dns-lookup?query=s1.disorbo.us&server=cloudflare

I get two A records at 15.197.143.173 and 3.33.152.147 (no SOA again), whilst a reverse lookup on these two IPs gives me Amazon hosts.

Again there are no AAAA records for s1.disorbo.us, but does list the SoA as disorbo.us

If I query s2.disorbo.us https://www.whatsmydns.net/dns-lookup?query=s2.disorbo.us&server=cloudflare

I get no A or AAAA records, but they both report the SOA as disorbo.us

So for me, assuming you want the various sub-domain entries to point to your public IP, your DNS entries are broken/missing.

Not being an Apache problem per se, am not sure we can help you much further with this one. Good luck!
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Wed 26 Apr '23 0:23    Post subject: Reply with quote

Hey I appreciate all the input I have received so far. Yes I have another server that runs a Godaddy DNS script ( GoDaddy.sh v1.0 by Nazar78 @ TeaNazaR.com http://teanazar.com/2016/05/godaddy-ddns-updater/
) I creates an A record with an @ and points it to my dynamic IP then I go and add forwarders with my subdomain names. I was doing a bunch of port forwarding but I really rather do VHOSTS and just use port 80 - Not sure what to do with $$# cuz my other box uses that for a cloud server.

I was dding a forwarder but perhaps I need a CNAME - I don;'t know DNS and I broke something because my other servers are not responding

again thank you
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Wed 26 Apr '23 0:31    Post subject: Reply with quote

Hey now adding a CNAME record makes it work so YOU ACTUALLY HAVE BEEN MOST HELPFUL!! T H A N K Y O U ! ! !
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Sun 30 Apr '23 20:31    Post subject: Reply with quote

I just found out this is NOT WORKING form the WAN so if I locally go to mysite.mydomain.com it works but if I call my buddy and say hey checkout my site mysite.mydomain.com it does not work for him
Back to top
tangent
Moderator


Joined: 16 Aug 2020
Posts: 333
Location: UK

PostPosted: Sun 30 Apr '23 23:09    Post subject: Reply with quote

Checking the above DNS entries, I can see a CNAME for s2.disorbo.us, but not for s1.disorbo.us which still has the two Amazon host A records.

Indeed, from the UK I get a login page at https://s2.disorbo.us, but nothing from https://s1.disorbo.us so guess you need a further CNAME entry.
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Mon 01 May '23 18:14    Post subject: Reply with quote

I was using s1 and s2 for testing and I have since removed them but let me put them back because I'm so close to getting this to work - its gotta be DNS - I wonder if there's a standard practice for DNS and VHOSTS
Back to top
DomDis



Joined: 21 Apr 2023
Posts: 12
Location: USA

PostPosted: Sat 20 May '23 1:46    Post subject: I think I figured it out But but now what Reply with quote

It seem my ISP blocks inbound port 80


OK so now what (other than getting another service provider)

This may be out of this forum's scope but can I do some DNSing to rout all port 80 to 8080 and still used Apache vhost - I guess I can add 8080 to Apache

or

do the DNS forwarding thing and hope my router can reroute it all to port 80 on the Apache server
Back to top


Reply to topic   Topic: Need Help getting Subdomains to work off one Apache instance View previous topic :: View next topic
Post new topic   Forum Index -> Apache