# SPDX-FileCopyrightText: 2023 Franco Masotti
#
# SPDX-License-Identifier: MIT

#############
# Nextcloud #
#############

# Required
Listen 8765

<IfModule mod_ssl.c>
<VirtualHost 127.0.0.1:8765>
    UseCanonicalName on

    ProxyPreserveHost On
    ProxyRequests off
    AllowEncodedSlashes NoDecode

    Keepalive On
    RewriteEngine on

    ServerName z7lsmsostnhiadxeuc6f5lto5jssa3j4c3jxaol6tvjavsxarf5agyyd.onion

    SSLCompression      off

    Header edit Location ^https://${NEXTCLOUD_DOMAIN}(.*)$ http://z7lsmsostnhiadxeuc6f5lto5jssa3j4c3jxaol6tvjavsxarf5agyyd.onion$1

    RequestHeader set X-Forwarded-Proto "http"
    # Distinguish normal traffic from tor's..
    RequestHeader set X-Forwarded-For "tor"
    RequestHeader set X-Forwarded-Port "80"
    RequestHeader set X-Forwarded-Host "z7lsmsostnhiadxeuc6f5lto5jssa3j4c3jxaol6tvjavsxarf5agyyd.onion"

    ProxyPass / http://127.0.0.1:4005/ keepalive=On
    ProxyPassReverse / http://127.0.0.1:4005/ keepalive=On
</VirtualHost>
</IfModule>
