Report deprecated http->https redirect in nginx conf

This commit is contained in:
Alexandre Aubin 2021-11-20 22:25:11 +01:00
parent 5c972a2607
commit 167f687643

View file

@ -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!" "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() @test()
def misc_nginx_add_header(self): def misc_nginx_add_header(self):