LKBEN11480: Nginx redirect or return 301 will lead to downloading a file when http is used


Symptom

The return 301 statement in the configuration file does not seem to work

Cause

The cause of this problem was - in our case - in a complete different file which had http2 defined for port 80

Solution

After configuring the website to redirect http traffic to https, we had problems with http requests when more then the main site was asked. The redirection would make a download.

The problem was found in another website configuration where http2 was added. The line in our case was:

listen 80 http2;

So you need to look in all sites available and if you find a site which is configured with http2 on port 80, you need to remove the http2 from the line.

You can use grep to check all the configuration files on the server with:

grep http2 *

...

listen 80 http2; #this was the problem!

...

If you find a line with includes 80 and http2, you edit this line and remove http2 from it. Restart nginx and test your website. In our case this helped and removed the download we had for the http websites. The https links did not have this problem and the http urls only had the download when an uri was contained in the browser.

e.g. http://www.lubby.org -> everything is fine

e.g. https://www.lubby.org/en/DB/details/LKBEN11476 -> everything is fine

e.g. http://lubby.org/en/DB/details/LKBEN11476 -> download!

Hope this helped.

Disclaimer:

The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!

About the Author

Author: Wim Peeters - Keskon GmbH & Co. KG

Wim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.

Latest update: 06-01-2021