diff --git a/roles/gitea/templates/app.ini.j2 b/roles/gitea/templates/app.ini.j2
index 39bda2087..cd2c79577 100644
--- a/roles/gitea/templates/app.ini.j2
+++ b/roles/gitea/templates/app.ini.j2
@@ -119,7 +119,7 @@ FILE_EXTENSIONS = .md,.markdown,.mdown,.mkd
; The protocol the server listens on. One of 'http', 'https', 'unix' or 'fcgi'.
PROTOCOL = http
DOMAIN = localhost
-ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s/
+ROOT_URL = %(PROTOCOL)s://%(DOMAIN)s:%(HTTP_PORT)s{{ gitea_url }}/
; The address to listen on. Either a IPv4/IPv6 address or the path to a unix socket.
HTTP_ADDR = 0.0.0.0
HTTP_PORT = {{ gitea_port }}
diff --git a/roles/gitea/templates/gitea.conf.j2 b/roles/gitea/templates/gitea.conf.j2
index ac9d9753f..b16f7ab2b 100644
--- a/roles/gitea/templates/gitea.conf.j2
+++ b/roles/gitea/templates/gitea.conf.j2
@@ -1,11 +1,17 @@
# All URLs go to Gitea web server. Static content is bundled in the executable.
+ProxyPreserveHost On
ProxyRequests off
-ProxyPass {{ gitea_url }}/ http://localhost:{{ gitea_port }}/
+
+
+ Order allow,deny
+ Allow from all
+
+
+# Note: no trailing slash after either {{ gitea_url }} or port
+ProxyPass {{ gitea_url }} http://localhost:{{ gitea_port }}
+ProxyPassReverse {{ gitea_url}} http://localhost:{{ gitea_port }}
- ProxyPassReverse /
- ProxyHTMLEnable On
- ProxyHTMLURLMap / {{ gitea_url }}/
RequestHeader unset Accept-Encoding