Redirect http to https ends in 400 Bad Request

Servus Community,

I have Nextcloud 20 installed on a Debian 10 system with Apache2 2.4 web server. With Letsencrypt a SSL certificate was installed and the request via the URL prefix https:// also works. However, when entering the page via the URL prefix http://, an error 400 Bad Request is issued.

I’ve been sitting on this for hours now and have tried just about everything I can find in terms of possible solutions.

The redirect statement was done in the Virtual Host Configuration by certbot:

<VirtualHost *:80>
      DocumentRoot /var/www/

     ErrorLog ${APACHE_LOG_DIR}/cloud.domain.de_error.log
     CustomLog ${APACHE_LOG_DIR}/cloud.domain.de_access.log combined

	SSLEngine on
        SSLCertificateFile /etc/letsencrypt/live/
        SSLCertificateKeyFile /etc/letsencrypt/live/
        SSLCertificateChainFile /etc/letsencrypt/live/

RewriteEngine on
RewriteCond %{SERVER_NAME}
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

I also added the following instruction but it did not change anything either:

RedirectPermanent /

The .htaccess file is unchanged. Other web projects (Wordpress) work fine with above changes.

Can anyone help localize the problem or know what the problem is?

Thx & Bye Tom

Servus Community,

I fixed the problem, there were still errors in the vhost configuration. Now it works and an http request is automatically redirected to https. That’s how it should be…

Thx & Bye Tom

1 Like