I'm using a personal VPS (Ubuntu 20, Apache2) to host a web app. Currently there are 2 static sites, site1.com and site2.org, both working.

I installed an app that is currently available on port 8065, e.g.: site2.org:8065

My question is, how can I set up Apache to make the app appear at mm.site2.org? (with the subdomain "mm").

I created a config file like this:

# /etc/apache2/sites-available/mm.site2.org.conf
<VirtualHost *:80>
    ServerName mm.site2.org

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

    ProxyRequests Off
    <Proxy http://localhost:8065/*>       
      Order deny,allow
      Allow from all
    ProxyPass /
    ProxyPassReverse /

    <Location />
      Order allow,deny
      Allow from all


After setting up the above, I've run the requisite commands to restart the services like this:

sudo a2ensite mm.site2.org.conf
sudo systemctl reload apache2
sudo service apache2 restart

I've also tried a variant of the <Proxy ...> line in the Apache conf file, based on some different sources, using simply <Proxy *> as some sources suggest.

If it is relevant, my DNS settings consist simply of two A records (@ and www) for each site.

The output of sudo apache2ctl -S is:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 12.345.67.890. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:443                  is a NameVirtualHost
         default server site1.com (/etc/apache2/sites-enabled/site1.com-le-ssl.conf:2)
         port 443 namevhost site1.com (/etc/apache2/sites-enabled/site1.com-le-ssl.conf:2)
                 alias www.site1.com
         port 443 namevhost site2.org (/etc/apache2/sites-enabled/site2.org-le-ssl.conf:2)
                 alias www.site2.org
*:80                   is a NameVirtualHost
         default server 12.345.67.890 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost 12.345.67.890 (/etc/apache2/sites-enabled/000-default.conf:1)
         port 80 namevhost site1.com (/etc/apache2/sites-enabled/site1.com.conf:1)
                 alias www.site1.com
         port 80 namevhost site2.org (/etc/apache2/sites-enabled/site2.org.conf:1)
                 alias www.site2.org
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
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
User: name="www-data" id=33
Group: name="www-data" id=33

No luck getting the webapp to appear on the subdomain desired.


Based on what you write, I think DNS isn't properly configured:

If it is relevant, my DNS settings consist simply of two A records (@ and www) for each site.

You must add a DNS RR for a subdomain, address: mm.site2.org. A 12.345.67.890, or cname (alias): mm.site2.org. CNAME www.site2.org.. To direct all subdomains to this server RR name may be a wildcard: *.site2.org. A 12.345.67.890 (CNAME RR will probably suffice too). (It seems you expected it already works like this.)

  • Thanks! This worked. You're right... I thought that either I needed to configure Apache, or I needed to set up another DNS entry. I apparently should have considered both :-) (I had already attempted to set another DNS entry, but I was focusing on CNAME. I didn't format it properly, NameCheap's validation was complaining, and I concluded from that that I must focus on Apache.) For others' benefit, the resource record I set was of type A, with simply "mm" for host and 12.345.67.890 for value. Cheers! – nivek Jan 13 at 3:03
  • Just for clarity: simple "mm" would get converted to "mm.site2.org." under the origin (context) of "site2.org." undet the hood. I wrote that in the most explicit form, because I didn't knew anything about features of zone editing interface available to you. Note dots at the end. The rule is: if the name ends with a dot, nothing needs to be appended (that's compete explicit form), if the name doesn't end with a dot, active context value needs to be appended (that may be origin if we talk about zone, or dns suffix if we talk about name resolution on a computer). – Nikita Kipriyanov Jan 13 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.