The requested <url> was not found on this server ... Apache (Ubuntu) server at <hostname> port 443"

My domain is: development.newcardeals.co.za

I ran this command: N/A

It produced this output: N/A

My web server is (include version):

Server version: Apache/2.4.58 (Ubuntu)
Server built:   2024-07-11T14:41:54

The operating system my web server runs on is (include version):

Distributor ID:  Ubuntu
Description:  Ubuntu 24.04 LTS
Release:  24.04
Codename:   noble

My hosting provider, if applicable, is: This is an AWS EC2 instance.

I can login to a root shell on my machine (yes or no, or I don't know): Yes.

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): NO.

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot):

certbot 2.11.0

Additional Context
I'm testing SSL certificate installation on a development environment i.e. dev.bar.co.za using HTTP. NB: bar is 'newcardeals' and dev is 'development'.

This is an error displayed after installing an SSL certificate through Let's Encrypt and accessing pages other than the home page.

"the requested url was not found on this server ... apache (ubuntu) server at dev.bar.co.za port 443"

This is /etc/apache2/sites-available/bar.conf

<VirtualHost *:80>
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  DocumentRoot /path/to/the/app/dir/
  ErrorLog ${APACHE_LOG_DIR}/error.log
  RewriteEngine on
  RewriteCond %{SERVER_NAME} =dev.bar.co.za
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
  ServerAdmin webmaster@localhost
  ServerName dev.bar.co.za
</VirtualHost>

And this is /etc/apache2/sites-available/bar-le-ssl.conf

<VirtualHost *:443>
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  DocumentRoot /path/to/the/app/dir/
  ErrorLog ${APACHE_LOG_DIR}/error.log
  SSLEngine on
  SSLCertificateFile /etc/letsencrypt/live/dev.bar.co.za/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/dev.bar.co.za/privkey.pem
  ServerAdmin webmaster@localhost
  ServerName dev.bar.co.za
  Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

This is the output of running sudo apache2ctl configtest

$ Syntax OK

This is the output of running sudo a2ensite bar.conf and sudo a2ensite bar-le-ssl.conf.

$ Site bar already enabled
$ Site bar-le-ssl already enabled

In addition, I can see symbolic links confirming the output below when I run sudo ls -al /etc/apache2/

This is the output of running sudo apache2ctl -M | grep ssl.

$ ssl_module (shared)

Unless if I'm wrong, the missing SSLEngine on line in bar-le-ssl.conf shouldn't be a problem. apache2ctl -M | grep ssl output confirms that the ssl module is loaded, so the configuration seems to be picking it up from there.

This is the output of running sudo a2enmod rewrite

$ Module rewrite already enabled

This is the output of running tail /var/apache2/error.log.

[Thu May 12 ...] [mpm_prefork:notice] [pid 55358] AH00163: Apache/2.4.58 (Ubuntu) OpenSSL/3.0.13 configured -- resuming normal operations
[Thu May 12 ...] [core:notice] [pid 55358] AH00094: Command line: '/usr/sbin/apache2'
[Thu May 12 ...] [mpm_prefork:notice] [pid 55358] AH00170: caught SIGWINCH, shutting down gracefully
[Thu May 12 ...] [mpm_prefork:notice] [pid 59090] AH00163: Apache/2.4.58 (Ubuntu) OpenSSL/3.0.13 configured -- resuming normal operations
[Thu May 12 ...] [core:notice] [pid 59090] AH00094: Command line: '/usr/sbin/apache2'
[Thu May 12 ...] [core:error] [pid 59481] [client 120.x.y.z:44096] AH10244: invalid URI path (/cgi-bin/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/.%2e/bin/sh)
[Thu May 12 ...] [core:error] [pid 59482] [client 120.x.y.z:47068] AH10244: invalid URI path (/cgi-bin/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/%%32%65%%32%65/bin/sh)

The error messages in /var/apache2/error.log don't seem related to the issue I'm facing.

Fixes I've Tried

  1. Verify DocumentRoot: Double-check that the DocumentRoot in bar-le-ssl.conf points to the actual directory containing your application files.
  2. Restart Apache: After making any configuration changes. Run sudo systemctl restart apache2 to apply them.
  3. Temporarily Disable Rewrite Rule: Try commenting out the rewrite rule in bar.conf and observe the behavior. If it fixes the issue, investigate application-level rewrite rules.

You mean this url gives a 404 error?

http://development.newcardeals.co.za/.well-known/acme-challenge/hi!

That's expected and perfectly normal. Is certbot complaining?

2 Likes

No. I mean accessing any URL from the web site gives this error in browser.

Not Found
The requested URL was not found on this server.
....
Apache/2.4.58 (Ubuntu) Server at development.newcardeals.co.za Port 443

What do you mean by cerbot complaining? Is there a command I can run on the terminal to determine if there are any errors?

The most error I get is a mixed content warning. I see no 404 everywhere.

% curl -IiL development.newcardeals.co.za
HTTP/1.1 301 Moved Permanently
Date: Fri, 12 Jul 2024 10:12:19 GMT
Server: Apache/2.4.58 (Ubuntu)
Location: https://development.newcardeals.co.za/
Content-Type: text/html; charset=iso-8859-1

HTTP/1.1 200 OK
Date: Fri, 12 Jul 2024 10:12:19 GMT
Server: Apache/2.4.58 (Ubuntu)
Cache-Control: no-cache
Set-Cookie: laravel_session=[...]; expires=Fri, 12-Jul-2024 12:12:28 GMT; Max-Age=7200; path=/; httponly
Content-Type: text/html; charset=UTF-8

You can check the certbot log.

3 Likes

Your website has a perfectly functional https capability using a LE certificate. This forum usually helps getting to this exact point but not beyond.

4 Likes

The most error I get is a mixed content warning. I see no 404 everywhere.

% curl -IiL development.newcardeals.co.za
HTTP/1.1 301 Moved Permanentl
....

I can confirm that running curl ... returns the same output you've shown however my problem is with accessing development.newcardeals.co.za through the Chrome (I'm sorry I wasn't clear what the agent is). I'm getting a 404 on the home page and likely any other page.

Thank you. I'll try asking the same question on a Stack Exchange site like Server Fault.

2 Likes

Try clearing the cache from developer tools? F12

3 Likes

Here are my observations in order.

  1. https://development.newcardeals.co.za loads fine.
  2. I tried to navigate away to https://development.newcardeals.co.za/new-cars/peugeot/landtrek/1-9td-double-cab-allure/217454 I got hit with a 404.
  3. I tried navigating to another "detail" page again and got hit with a 404.
  4. I've confirmed that both pages are accessible on the live web site.

Here is how I cleared the cache from Developer Tools

  1. Pressed the F12 key on the keyboard which opened the Developer Tools on the right.
  2. Right-clicked the Reload button (upper-left), and selected Empty cache and hard reload button.

I can confirm that. I don't think it's something we can help with.

4 Likes

Thank you for your time. I'll ask the question on a relevant Stack Exchange site.

3 Likes

Hi @tafadzwagonera,

Here details on Apache can be found in documentation and forums:

3 Likes

I've gone through the apache2 configuration and documentation at least twice and am unable to determine whether there's a configuration that could be potential cause. The original post documents these observations in detail which is why I came to this forum first. Thank you for the links though.

1 Like

I mean, I assumed it was your php app responding with 404, not apache.

4 Likes

That's an interesting point. While I've successfully deployed the application on my local machine, this leads me to question whether the issue lies with Laravel itself.

Or apache isn't passing stuff to laravel properly. I don't know. I have no idea how laravel works.

2 Likes

Or apache isn't passing stuff to laravel properly. I don't know.

It's possible, but I'm not familiar with Apache deployments for PHP. My experience lies mainly in JavaScript and Java. I'll definitely look into it though. Thanks for your time!

1 Like

It turns out the issue stemmed from permissions on the .htaccess file located in /path/to/public_html/ . By adding the <Directory> directive in the Apache configuration to grant the necessary permissions, I could navigate the web site again.

Here's my final vhost configuration for port 80 and port 443.

<VirtualHost *:80>
  # ... Other configuration
  RewriteEngine on
  RewriteCond %{SERVER_NAME} =dev.bar.co.za
  RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

  <Directory /path/to/the/app/dir/>
    AllowOverride All
  </Directory>
  # ... Rest of configuration
</VirtualHost>
<VirtualHost *:443>
  # ... Other configuration
  SSLEngine on
  SSLCertificateFile /etc/letsencrypt/live/dev.bar.co.za/fullchain.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/dev.bar.co.za/privkey.pem
  ServerAdmin webmaster@localhost
  ServerName dev.bar.co.za
  Include /etc/letsencrypt/options-ssl-apache.conf

  <Directory /path/to/the/app/dir/>
    AllowOverride All
  </Directory>
  # ... Rest of configuration
</VirtualHost>

I saw this solution before and had ruled it off because the initial assumption about what the issue could be was wrong. Humph!

NB: The directives i.e. AllowOverride All in <Directory> directive aren't exhaustive at all. I've added the least amount of directives to solve my problem.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.