LaVOZs

The World’s Largest Online Community for Developers

'; Published ASP.NET Core application on Apache can be accessed through IP, but not through domain - LavOzs.Com

I have an ASP.NET Core application on Linux with Apache that I can access using http://[::]:5000, but not through https://example.com/Panel (404 error) or https://example.com:5000 (connection closed error).

Apache config:

<IfModule mod_ssl.c>
<VirtualHost *:80>
        ServerName example.com
        DocumentRoot /var/www/html
        ServerAdmin me@example.com

        RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}

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

<VirtualHost *:443>
        ServerName example.com
        DocumentRoot /var/www/html
        ServerAdmin me@example.com

        RequestHeader set "X-Forwarded-Proto" expr=%{REQUEST_SCHEME}

        RewriteEngine On
        ErrorLog "/var/log/apache2/rewrite"
        LogLevel alert rewrite:trace6

        ProxyRequests Off
        ProxyVia Off
        ProxyPreserveHost On

        <Proxy *>
                Require all granted
        </Proxy>

        ProxyPass /Panel http://localhost:5000/Panel
        ProxyPassReverse /Panel http://localhost:5000/Panel

        SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Program.cs:

public class Program {
    public static void Main(string[] args) {
        CreateHostBuilder(args).Build().Run();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder => {
                webBuilder.UseUrls("http://*:5000");
                webBuilder.UseStartup<Startup>();
            });
    }

What should be done in order to make it available through https://example.com/Panel? I suppose it's related to Kestrel, I tried to add something like UseUrls("http://*:5000;https://example.com:5000") to Program.cs but then the server wouldn't launch at all.

Edit: I forgot to mention that my Startup.cs has this line:

app.UsePathBase("/Panel");

Why doesn't this work? I followed this guide step by step.

Related
redmine and mod_vhost_dbd
Access the current HttpContext in ASP.NET Core
How do you create a custom AuthorizeAttribute in ASP.NET Core?
Resolving instances with ASP.NET Core DI
Publish rc2 asp.net core application to Azure
How to specify the port an ASP.NET Core application is hosted on?
ASP.NET Core Web API exception handling
Asp.net core publish apache
Can't Run ASP.NET Core on Centos7(Apache)