system-config/playbooks/roles/gitea/templates/gitea.vhost.j2
Clark Boylan 2fb310972c Update gitea logs for better request tracing
In gitea 1.14.0 they dropped the macaron http router for go-chi. This
seems to have changed how the request context's RemoteAddr is parsed in
logging. Importantly instead of a valid source port we get :0 which
makes it difficult to trace a connection from apache to gitea.

The origin of this behavior seems to be handling of X-Forwarded-For
headers that apache is setting. To address this we drop those headers
in hopes that gitea will log raw details for the apacher -> gitea
connection in that case. Due to not using x-forwarded-for anymore we
need to log the source port that apache is using for the proxy pass
connection which is done by modifying the apache log format.

Change-Id: I1e69431bf703947dc5c223df2a9e1b55bd0d841c
2022-09-30 11:29:58 -07:00

49 lines
1.5 KiB
Django/Jinja

Listen 3081
<VirtualHost *:3081>
ServerName {{ inventory_hostname }}
ServerAdmin infra-root@opendev.org
DocumentRoot /var/www/opendev.org
<Directory /var/www/opendev.org/>
Require all granted
Order allow,deny
Allow from all
</Directory>
AllowEncodedSlashes On
ErrorLog ${APACHE_LOG_DIR}/gitea-ssl-error.log
LogLevel warn
LogFormat "%h:%{remote}p %A:%{proxy-source-port}n %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combinedport
CustomLog ${APACHE_LOG_DIR}/gitea-ssl-access.log combinedport
SSLEngine on
SSLProtocol All -SSLv2 -SSLv3
# Note: this list should ensure ciphers that provide forward secrecy
SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:!AES256:!aNULL:!eNULL:!MD5:!DSS:!PSK:!SRP
SSLHonorCipherOrder on
SSLCertificateFile /etc/letsencrypt-certs/{{ inventory_hostname }}/{{ inventory_hostname }}.cer
SSLCertificateKeyFile /etc/letsencrypt-certs/{{ inventory_hostname }}/{{ inventory_hostname }}.key
SSLCertificateChainFile /etc/letsencrypt-certs/{{ inventory_hostname }}/ca.cer
SSLProxyEngine on
<Location /.well-known/matrix/client>
Header set Access-Control-Allow-Origin "*"
</Location>
Use UserAgentFilter
# Disable x-forwarded- headers because gitea logging can't
# parse them properly
ProxyAddHeaders Off
ProxyPass /.well-known/ !
ProxyPass / https://{{ inventory_hostname }}:3000/ retry=0
ProxyPassReverse / https://{{ inventory_hostname }}:3000/
</VirtualHost>