summaryrefslogtreecommitdiff
path: root/etc/httpd/conf/httpd.conf
blob: 675241d0cbe057e93e1cc15c7b9cdb4228294438 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
#
# Apache Server Configuration

ServerRoot /etc/httpd

#
# Load Modules
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule mime_module modules/mod_mime.so
LoadModule dir_module modules/mod_dir.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule alias_module modules/mod_alias.so
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule expires_module modules/mod_expires.so
# And Basic Auth Modules
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_user_module modules/mod_authz_user.so
# Load CGI Module
<IfModule !mpm_prefork_module>
   LoadModule cgid_module modules/mod_cgid.so
</IfModule>
<IfModule mpm_prefork_module>
   LoadModule cgi_module modules/mod_cgi.so
</IfModule>

#
# Server config
Listen 80
ServerName localhost
EnableSendFile on
AddDefaultCharset UTF-8
TypesConfig /etc/mime.types
MIMEMagicFile conf/magic
AddHandler cgi-script .cgi

#
# Log Config
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
ErrorLog "logs/error_log"
ScriptLog logs/git-http-debug.log
CustomLog "logs/access_log" combined

#
# Git Smart HTTP Support (if enabled)
PassEnv GIT_HTTP_AUTH_FILE
IncludeOptional conf.d/git-http.conf

#
# Always wear protection.
<Directory />
    Require all granted
</Directory>

#
# ALSO: cgitrc must have this: virtual-root=/
DocumentRoot "/srv/www/htdocs/cgit"
<Directory "/srv/www/htdocs/cgit">
    Require all granted
    # -Indexes here is not strictly necessary;
    # Added for good hygiene
    Options +ExecCGI -Indexes
    DirectoryIndex cgit.cgi
    AllowOverride All

    RewriteEngine On
    
    # Hard stop: never rewrite Git HTTP requests.
    RewriteRule ^.+/(git-upload-pack|git-receive-pack|info/refs)$ - [END]
    
    # Serve static files directly.
    RewriteCond %{REQUEST_FILENAME} -f
    RewriteRule ^ - [END]

    # Let cgit handle everything else (and stay off my url).
    RewriteRule ^(.*)$ cgit.cgi/$1 [END]

    # Cache static assets
    ExpiresActive On
    <FilesMatch "\.(css|js|png|ico)$">
        ExpiresDefault "access plus 30 days"
        Header set Cache-Control "public, max-age=2592000, immutable"
    </FilesMatch>
</Directory>

# Deny access to .htaccess/.htpasswd.
<Files ".ht">
    Require all denied
</Files>