Websites SSL mixing with dashboard domain SSL

Hello everyone,

I’m excited to be trying out this fantastic tool! I’ve encountered a few issues as a beginner and would appreciate your help.

Environment

I have a fresh install on my system:

  • AlmaLinux 8.10
  • ApisCP Version 3.2.0-740115fbe (latest version)

I just ran the command # upcp -sb, and here’s what I got:

localhost                  : ok=1533 changed=50   unreachable=0    failed=0    skipped=787  rescued=1    ignored=0

Description

My VPS operates on LAN/NAT, and I can access both the ApisCP dashboard (ports 2082/2083) and the websites I’ve created (ports 80/443). The Let’s Encrypt SSL works perfectly for the main dashboard domain on port 2083.

However, I need help with the SSL for user websites. The system indicates “Certificate Detected,” valid from 2024/10/30 to 2025/01/28.

In the file /etc/httpd/conf/virtual/site1, I see these lines:

SSLCertificateKeyFile /home/virtual/site1/fst//etc/httpd/conf/ssl.key/server.key
SSLCertificateFile /home/virtual/site1/fst//etc/httpd/conf/ssl.crt/server.crt

And I’ve confirmed that those certificate files exist.

Actual Behavior

Despite this, when I visit https://user-domain.com, the SSL certificate loading in my browser is the one from the ApisCP dashboard domain, not the intended user-domain.com certificate. I also tried creating another user and website/domain but encountered the same SSL issue.

Expected Behavior

The https://user-domain.com shows the SSL for user-domain.com.

Please guide me in ensuring the correct SSL certificate for the created websites.

Thank you so much for your help!

What does htrebuild report from the command-line? When installing a SSL certificate, there’s a 2 minute delay to elide successive HTTP reloads. Once that timer elapses, the new configuration is compiled and Apache restarted.

Based upon the server returning the server certificate, which is a fallthrough case if SSL is unmatched, either Apache couldn’t reload - htrebuild will notify you if so or the IP address for the site (ipinfo,nbaddrs service value in Nexus) isn’t matching with the IP you’re accessing it as while behind the NAT. See also NAT.md.

Hi,

# htrebuild
Reloading httpd: Syntax OK

This VPS has a single IP; the user websites can be accessed on ports 80 and 443 (but with SSL error). So, the NAT is not the cause.

But I saw another issue and don’t know if it can affect this case.

My NAT has the gateway IP xxx.xxx.xxx.229, which goes to a pfsense.
During the ApisCP installation, the gateway IP was automatically used as the server address.

I changed it, and currently, my IP settings are:

dns.ip4-pool : 192.168.1.132
dns.ip4-proxy: xxx.xxx.xxx.228

In the admin dashboard /apps/nexus and in /apps/stats

It shows the dashboard domain name and the gateway IP (xxx.xxx.xxx.229), not the dns.ip4-proxy: xxx.xxx.xxx.228.

I could not fix it.

  • Do you think this IP mismatch is related to this issue?
  • How can I replace all occurrences of the gateway IP (xxx.xxx.xxx.229) by the VPS IP (xxx.xxx.xxx.228)?

Thanks again.

Yes, this is how Apache resolves virtualhosts. When no named servername/serveralias + IP:PORT combination matches, it falls through to the server VirtualHost. Take for example, apiscp.com; for me it’s in /etc/httpd/conf/virtual/site1:

        <VirtualHost 64.22.68.70:443>
            ServerName www.apiscp.com
        ServerAlias apiscp.com *.apiscp.com
        DocumentRoot /home/virtual/site1/fst/var/www/html

                ServerAlias panel.dev *.panel.dev

In order for this container to match, a HTTP request for “apiscp.com” must arrive on the interface that binds 64.22.68.70. Moreover, the HTTP request must have originated from a connection opened to 64.22.68.70. If I were to access it within my LAN and let’s say in I have an override in my hosts file for apiscp.com to 192.168.1.30, then this wouldn’t match because the destination IP of the request uses 192.168.1.30, which doesn’t match.

NB: Likewise the same container is matched if the HTTP hostname is panel.dev.

That’s correct behavior. The IP address shown is the publicly reachable one, not internal.

Absolutely.

See NAT.md > Changing IPs.

The file /etc/httpd/conf/virtual/site1 includes the following VirtualHost configurations:

<VirtualHost 192.168.1.132:80>
...
<VirtualHost 192.168.1.132:443>
...

It appears there are no issues with the public IPs on Apache since it is using a private one.

From what I understand, these instructions are meant for public IPs, not for NAT setups.

Here are my current IP settings:

dns.ip4-pool : 192.168.1.132
dns.ip4-proxy: xxx.xxx.xxx.228

Please comment on it.

Thanks.

Same scenario, nomenclature is different. There’s a single public IP (xxx.xxx.xxx.228), it passes through your router, then the IP is translated into the internal network address (192.168.1.132).

Here’s how I understand your network setup:
Untitled Diagram.drawio

Here’s a simple test to run on a machine outside your network:

curl --resolve user-domain.com:80:xxx.xxx.xxx.228 --resolve user-domain.com:443:xxx.xxx.xxx.228 https://user-domain.com/

This should complete without a SSL warning. If it does, then you have an issue within your NAT accessing the server from a local desktop. If it does not, then there’s an issue with pfSense forwarding the packets to your server, specifically it’s connecting to the server on an IP other than 192.168.1.132.

Out of curiosity, is the SSL Organization listed under Web > SSL Certificates listed as “Let’s Encrypt - E5” for the account? Tracking a separate issue, which I think may be related to yours.

First of all, thank you for this amazing support.

Here are some tests I made:

1 test

curl --resolve user-domain.com:80:xxx.xxx.xxx.228 --resolve user-domain.com:443:xxx.xxx.xxx.228 https://user-domain.com/

I got:
curl: (51) SSL: no alternative certificate subject name matches target host name ‘user-domain.com

  • On both lines above, I replaced the “user-domain.com” and the IPs with the real info on my tests.

2 test, a variation from the first:

I ran the same command but used the private IP 192.168.1.132 instead of the public one.
Got the same response.

3 test:

# openssl x509 -in /home/virtual/site1/fst//etc/httpd/conf/ssl.crt/server.crt -text -noout

Output:

Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            03:ff:68:f1:2b:ba:2b:9f:7c:c2:71:f8:b8:f6:61:ea:00:32
        Signature Algorithm: ecdsa-with-SHA384
        Issuer: C = US, O = Let's Encrypt, CN = E5
        Validity
            Not Before: Oct 30 04:27:54 2024 GMT
            Not After : Jan 28 04:27:53 2025 GMT
        Subject: CN = user-domain.com (* replaced)
...

The certificate info shows the “Let’s Encrypt, CN = E5” data.

Any thoughts?

Thank you again.

This test was intended to avoid dealing with NAT and pfsense issues.
Using the private IP in the curl command and loading the HTTP://, we get the correct website.
Using HTTPS://, we get the SSL error.

Got it. Commit 3 days ago removed a trailing empty linebreak, which resulted in SSLEngine running onto the previous line.

Run the following commands:

upcp
EditDomain --reconfig --all

Should be good to go then :+1:

# upcp
EditDomain --reconfig --all 

From https://gitlab.com/apisnetworks/apnscp
   740115fbe..fdd805641  master     -> origin/master

I repeated the 3 above tests and rebooted the server, and the issue persists.

Running a second time the command “EditDomain --reconfig --all” , I got this:

INFO   : DNS not configured for `user-domain.com', skipping edit hook

Since I am using an external DNS server, should this interfere with this fix?

Run htrebuild. There’s a 2 minute delay when configuration is compiled down, so it’s possible you rebooted before this had time to process. The remarkable change is that in, for example /etc/httpd/conf/virtual/site1, the following line:

        Include /etc/httpd/conf/site1 SSLEngine On
                SSLCertificateKeyFile /home/virtual/site1/fst//etc/httpd/conf/ssl.key/server.key

is correctly rendered as:

        Include /etc/httpd/conf/site1
                SSLEngine On
                SSLCertificateKeyFile /home/virtual/site1/fst//etc/httpd/conf/ssl.key/server.key
1 Like

I confirm the file was like this; it was a good catch.

However, the new line was not automatically inserted, so I created it manually.
After a reboot and a few Apache restarts … it works! :+1:

Thank you so much for all your team, and I will let you know if I face this issue again when creating new domains.

Congratz on this great support.