apache: Don't redirect to HTTPS for .onion domains

Tests:

- Without the patch, run torsocks curl -kv http://DOMAIN.onion. Observe that
redirection to https happens.

- Without the patch, run curl -kv http://localhost. Observe that redirection to
https happens.

- With the patch, run torsocks curl -kv http://DOMAIN.onion. Observe that
redirection to https does not happen.

- With the patch, run curl -kv http://localhost. Observe that redirection to
https happens.

[sunil: Perform case insensitive match]
[sunil: Remove capture of domain name match]
[sunil: Strictly check that domain ends with .onion]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Tested-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Benedek Nagy 2022-01-15 23:49:50 +00:00 committed by Sunil Mohan Adapa
parent 44bff730f3
commit e7399a4d8e
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -10,6 +10,9 @@
##
<Location /plinth>
RewriteEngine on
# Don't redirect for onion sites as it is not needed and leads to
# unnecessary warning.
RewriteCond %{HTTP_HOST} !^.*\.onion$ [NC]
ReWriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</Location>