-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.conf
205 lines (190 loc) · 7.83 KB
/
index.conf
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
{# This configuration is based on wordpress_composer.conf and any changes to
# this file should be duplicated there, as appropriate.
-#}
# vim: ft=apache:
<VirtualHost *:443>
ServerName {{ SERVER_NAME }}
ErrorLog ${APACHE_LOG_DIR}/{{ SERVER_NAME }}_error.log
CustomLog ${APACHE_LOG_DIR}/{{ SERVER_NAME }}_access.log combined
SSLEngine on
SSLCertificateFile {{ LE_CERT_PATH }}/fullchain.pem
SSLCertificateKeyFile {{ LE_CERT_PATH }}/privkey.pem
RewriteEngine On
# Log Rewrite actions (use trace1 - trace8 for detailed logging)
LogLevel rewrite:warn
###########################################################################
# CC Legal Tools
# Directory Aliases
Alias /status /var/www/git/cc-legal-tools-data/docs/status
Alias /rdf /var/www/git/cc-legal-tools-data/docs/rdf
Alias /publicdomain /var/www/git/cc-legal-tools-data/docs/publicdomain
Alias /licenses /var/www/git/cc-legal-tools-data/docs/licenses
Alias /cc-legal-tools /var/www/git/cc-legal-tools-data/docs/cc-legal-tools
# File Aliases
Alias /schema.rdf /var/www/git/cc-legal-tools-data/docs/rdf/schema.rdf
Alias /ns.html /var/www/git/cc-legal-tools-data/docs/rdf/ns.html
Alias /ns /var/www/git/cc-legal-tools-data/docs/rdf/ns.html
<Directory /var/www/git/cc-legal-tools-data/docs>
# Disable .htaccess (for security and performance)
AllowOverride None
# Also serve HTML files without .html extension
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule !.*\.html$ %{REQUEST_FILENAME}.html [L]
# Redirect .../index.php to .../
RewriteCond %{REQUEST_FILENAME} "index\.php$" [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*/)index\.php$ $1 [L,NC,R=301]
# Deny access to PHP files (content should be only static files)
RewriteRule .*\.php$ "-" [F,L]
# Correct mimetype for .../rdf files
RewriteRule (.*/rdf$) $1 [T=application/rdf+xml]
</Directory>
###########################################################################
# Chooser
# Alias /choose /var/www/git/chooser/docs
# <Directory /var/www/git/chooser/docs>
# # Disable .htaccess (for security and performance)
# AllowOverride None
# # Redirect .../index.php to .../
# RewriteCond %{REQUEST_FILENAME} "index\.php$" [NC]
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteRule (.*/)index\.php$ $1 [L,NC,R=301]
# # Deny access to PHP files (content should be only static files)
# RewriteRule .*\.php "-" [F,L]
# </Directory>
RedirectPermanent /choose/zero /choose
RedirectPermanent /chooser /choose
RedirectTemp /choose https://chooser-beta.creativecommons.org
###########################################################################
# FAQ
Alias /faq /var/www/git/faq/faq
<Directory /var/www/git/faq/faq>
# Disable .htaccess (for security and performance)
AllowOverride None
# Redirect .../index.php to .../
RewriteCond %{REQUEST_FILENAME} "index\.php$" [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*/)index\.php$ $1 [L,NC,R=301]
# Deny access to PHP files (content should be only static files)
RewriteRule .*\.php "-" [F,L]
</Directory>
###########################################################################
# Platform Toolkit
Alias /platform/toolkit /var/www/git/mp/docs
<Directory /var/www/git/mp/docs>
# Disable .htaccess (for security and performance)
AllowOverride None
# Redirect .../index.php to .../
RewriteCond %{REQUEST_FILENAME} "index\.php$" [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*/)index\.php$ $1 [L,NC,R=301]
# Deny access to PHP files (content should be only static files)
RewriteRule .*\.php "-" [F,L]
</Directory>
###########################################################################
# WordPress/Default
DocumentRoot {{ DOCROOT }}
<Directory {{ DOCROOT }}>
{%- if salt.pillar.get("apache2:stage_username", false) and salt.pillar.get("apache2:stage_password", false) %}
AuthType Basic
AuthName "Restricted Content"
AuthUserFile /var/www/htpasswd
Require valid-user
{%- endif %}
AllowOverride AuthConfig Limit Options FileInfo
Options +FollowSymLinks -Indexes
<Files .env>
Require all denied
</Files>
</Directory>
<Directory {{ DOCROOT }}/backup>
AllowOverride None
Require all denied
</Directory>
<Directory {{ DOCROOT }}/wp/wp-admin/includes>
AllowOverride None
Require all denied
</Directory>
<Directory {{ DOCROOT }}/wp/wp-includes/theme-compat>
AllowOverride None
Require all denied
</Directory>
<Directory {{ DOCROOT }}/wp-content/uploads>
AllowOverride None
<FilesMatch "[.]ph(?:p\d?|t|tml)$">
Require all denied
</FilesMatch>
</Directory>
<FilesMatch "^[.]?wp-config[.]php">
Require all denied
</FilesMatch>
# Default Index
RewriteRule ^(/)?$ /wp/index.php [L]
# WP-API
RewriteRule ^(/wp-json/.*)$ /wp/index.php$1 [L]
# Permalinks (for dirs/files not found)
# https://codex.wordpress.org/Using_Permalinks
# Directory Conditions
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp
RewriteCond %{REQUEST_URI} !^/status
RewriteCond %{REQUEST_URI} !^/rdf
RewriteCond %{REQUEST_URI} !^/publicdomain
RewriteCond %{REQUEST_URI} !^/platform/toolkit
RewriteCond %{REQUEST_URI} !^/licenses
RewriteCond %{REQUEST_URI} !^/faq
RewriteCond %{REQUEST_URI} !^/choose
RewriteCond %{REQUEST_URI} !^/cc-legal-tools
# File Conditions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/schema.rdf$
RewriteCond %{REQUEST_URI} !^/ns.html$
RewriteCond %{REQUEST_URI} !^/ns$
# Rule
RewriteRule . /wp/index.php [L]
# Serve non-/wp-content/ out of /wp/ (for dirs/files not found)
# https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
# Directory Conditions
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_URI} !^/wp-content/
RewriteCond %{REQUEST_URI} !^/status
RewriteCond %{REQUEST_URI} !^/rdf
RewriteCond %{REQUEST_URI} !^/publicdomain
RewriteCond %{REQUEST_URI} !^/platform/toolkit
RewriteCond %{REQUEST_URI} !^/licenses
RewriteCond %{REQUEST_URI} !^/faq
RewriteCond %{REQUEST_URI} !^/choose
RewriteCond %{REQUEST_URI} !^/cc-legal-tools
# File Conditions
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/schema.rdf$
RewriteCond %{REQUEST_URI} !^/ns.html$
RewriteCond %{REQUEST_URI} !^/ns$
# Rule
RewriteRule ^/(.*)$ /wp/$1
</VirtualHost>
<VirtualHost *:80>
ServerName ${HTTP_HOST}
ErrorLog ${APACHE_LOG_DIR}/{{ SERVER_NAME }}_error.log
CustomLog ${APACHE_LOG_DIR}/{{ SERVER_NAME }}_access.log combined
# Enable Let's Encrypt verification
Alias /.well-known/acme-challenge /var/www/html/.well-known/acme-challenge
<Directory /var/www/html/.well-known/acme-challenge>
Options None
AllowOverride None
ForceType text/plain
RedirectMatch 404 "^(?!/\.well-known/acme-challenge/[\w-]{43}$)"
</Directory>
# Enable WordPress migrations
Alias /cache-uploads {{ DOCROOT }}/cache-uploads
<Directory {{ DOCROOT }}/cache-uploads>
AllowOverride None
# Options default is FollowSymlinks
Require local
</Directory>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/cache-uploads [NC]
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
</VirtualHost>