diff --git a/package_linter.py b/package_linter.py index e56ac95..58d30be 100755 --- a/package_linter.py +++ b/package_linter.py @@ -1103,6 +1103,29 @@ class Configurations(TestSuite): "DO NOT run the app PHP worker as root or www-data! Use a dedicated system user for this app!" ) + @test() + def nginx_https_redirect(self): + + app = self.app + + for filename in ( + os.listdir(app.path + "/conf") if os.path.exists(app.path + "/conf") else [] + ): + # Ignore subdirs or filename not containing nginx in the name + if ( + not os.path.isfile(app.path + "/conf/" + filename) + or "nginx" not in filename + ): + continue + + content = open(app.path + "/conf/" + filename).read() + if "if ($scheme = http)" in content and "rewrite ^ https" in content: + yield Info( + "Since Yunohost 4.3, the http->https redirect is handled by the core, " + "therefore having an if ($scheme = http) { rewrite ^ https://... } block " + "in the nginx config file is deprecated. (This helps with supporting Yunohost-behind-reverse-proxy use case)" + ) + @test() def misc_nginx_add_header(self):