This repository has been archived by the owner on Jun 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
apache-vhost.conf.erb
358 lines (271 loc) · 11.2 KB
/
apache-vhost.conf.erb
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<% if @params[:ssl] %>
<VirtualHost <%= @params[:site]['secure_ip'] || '*' %>:<%= @params[:magento]['apache']['secure_port'] %>>
SSLEngine on
SSLCertificateKeyFile <%= @params[:site]['ssl']['keyfile'] %>
SSLCertificateFile <%= @params[:site]['ssl']['certfile'] %>
<% if defined?(@params[:site]['ssl']['cacertfile']) and !@params[:site]['ssl']['cacertfile'].nil? %>
SSLCACertificateFile <%= @params[:site]['ssl']['cacertfile'] %>
<% end %>
<% if defined?(@params[:site]['ssl']['certchainfile']) and !@params[:site]['ssl']['certchainfile'].nil? %>
SSLCertificateChainFile <%= @params[:site]['ssl']['certchainfile'] %>
<% end %>
SSLProtocol <%= @params[:site]['ssl']['protocols'] %>
SSLCipherSuite <%= @params[:site]['ssl']['ciphersuite'] %>
<% else %>
<VirtualHost *:<%= @params[:magento]['apache']['unsecure_port'] %>>
<% end %>
ServerName <%= @params[:site][:servername] %>
<% if defined?(@params[:site][:server_alias]) and !@params[:site][:server_alias].nil? %>
ServerAlias <% @params[:site][:server_alias].each do |a| %><%= a %> <% end %>
<% end %>
DocumentRoot <%= @params[:magento]['dir'] %>
LogLevel info
ErrorLog <%= @params[:apache]['log_dir'] %>/<%= @params[:site][:servername] %>-error.log
CustomLog <%= @params[:apache]['log_dir'] %>/<%= @params[:site][:servername] %>-access.log combined
ServerSignature Off
<% if @params[:site]['developer_mode'] %>
SetEnv MAGE_IS_DEVELOPER_MODE true
<% end %>
<% if @params[:site][:run_code] %>
SetEnv MAGE_RUN_CODE <%= @params[:site][:run_code] %>
<% end %>
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory <%= @params[:magento]['dir'] %>>
Options FollowSymLinks
EnableMMAP <%= @params[:magento]['apache']['enable_mmap'] %>
EnableSendfile <%= @params[:magento]['apache']['enable_sendfile'] %>
<% if @params[:apache]['basic_username'] %>
<% if @params[:apache]['allow_from'] %>
Satisfy Any
<% end %>
AuthUserFile <%= @params[:magento]['dir'] %>/.htpasswd
AuthType Basic
AuthName "Protected System"
Require valid-user
SetEnvIf Request_URI ^/LICENSE.txt$ noauth=1
Allow from env=noauth
<% end %>
<% if @params[:magento]['apache']['parse_htaccess'] %>
AllowOverride All
<% else %>
## Apache optimisation by disabling the .htaccess parsing
## Directives for securing directorys have been added to this file
AllowOverride None
<% end %>
Order allow,deny
<% if @params[:apache]['allow_from'] %>
<% @params[:apache]['allow_from'].each do |ip| %>
Allow from <%= ip %>
<% end %>
<% else %>
Allow from all
<% end %>
############################################
## uncomment these lines for CGI mode
## make sure to specify the correct cgi php binary file name
## it might be /cgi-bin/php-cgi
# Action php5-cgi /cgi-bin/php5-cgi
# AddHandler php5-cgi .php
############################################
## GoDaddy specific options
# Options -MultiViews
## you might also need to add this line to php.ini
## cgi.fix_pathinfo = 1
## if it still doesn't work, rename php.ini to php5.ini
############################################
## this line is specific for 1and1 hosting
#AddType x-mapp-php5 .php
#AddHandler x-mapp-php5 .php
############################################
## default index file
DirectoryIndex index.php
<IfModule mod_php5.c>
############################################
## adjust memory limit
# php_value memory_limit 64M
php_value memory_limit <%= @params[:php]['memory_limit'] %>
############################################
## php tuning
php_value max_execution_time <%= @params[:php]['max_execution_time'] %>
php_value display_errors <%= @params[:php]['display_errors'] %>
php_value html_errors <%= @params[:php]['html_errors'] %>
php_value upload_max_filesize <%= @params[:php]['upload_max_filesize'] %>
############################################
## disable magic quotes for php request vars
php_flag magic_quotes_gpc off
############################################
## disable automatic session start
## before autoload was initialized
php_flag session.auto_start off
php_flag session.gc_maxlifetime 3600
############################################
## enable resulting html compression
#php_flag zlib.output_compression on
###########################################
# disable user agent verification to not break multiple image upload
php_flag suhosin.session.cryptua off
###########################################
# turn off compatibility with PHP4 when dealing with objects
php_flag zend.ze1_compatibility_mode Off
</IfModule>
<IfModule mod_security.c>
###########################################
# disable POST processing to not break multiple image upload
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<IfModule mod_deflate.c>
############################################
## enable apache served files compression
## http://developer.yahoo.com/performance/rules.html#gzip
# Insert filter on all content
###SetOutputFilter DEFLATE
# Insert filter on selected content types only
AddOutputFilterByType DEFLATE text/css application/x-javascript text/javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon
#
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
<IfModule mod_ssl.c>
############################################
## make HTTPS env vars available for CGI mode
SSLOptions StdEnvVars
</IfModule>
<IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
# RewriteLog <%= @params[:apache]['log_dir'] %>/<%= @application_name %>-rewrite.log
# RewriteLogLevel 0
############################################
## you can put here your magento root folder
## path relative to web root
#RewriteBase /
<% if @params[:site]['additional_rewites'] != "" %>
# Write any additional rewrite configuration
<%= @params[:site]['additional_rewites'] %>
<% end %>
RewriteRule ^server-status - [L]
############################################
## workaround for HTTP authorization
## in CGI environment
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
############################################
## always send 404 on missing files in these folders
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
############################################
## never rewrite for existing files, directories and links
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
############################################
## rewrite everything else to index.php
RewriteRule .* index.php [L]
</IfModule>
AddType application/x-font-woff woff
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType image/jpg "access plus 6 months"
ExpiresByType image/png "access plus 6 months"
ExpiresByType image/jpeg "access plus 6 months"
ExpiresByType image/gif "access plus 6 months"
ExpiresByType image/png "access plus 6 months"
ExpiresByType text/plain "access plus 6 months"
ExpiresByType text/ico "access plus 6 months"
ExpiresByType image/ico "access plus 6 months"
ExpiresByType image/icon "access plus 6 months"
ExpiresByType image/x-icon "access plus 6 months"
ExpiresByType application/x-font-woff "access plus 6 months"
ExpiresByType application/x-shockwave-flash "modification plus 6 months"
ExpiresByType text/css "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType text/xml "modification plus 2 hours"
ExpiresByType image/vnd.microsoft.icon "access plus 6 months"
</IfModule>
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
<FilesMatch "\.(ico|jpe?g|png|gif|swf|css|gz|js|woff)$">
Header set Cache-Control "public, max-age=2592000"
</FilesMatch>
</IfModule>
############################################
## Prevent character encoding issues from server overrides
## If you still have problems, use the second line instead
AddDefaultCharset Off
#AddDefaultCharset UTF-8
############################################
## If running in cluster environment, uncomment this
## http://developer.yahoo.com/performance/rules.html#etags
FileETag none
# FileETag MTime Size
</Directory>
<%
[
'/app',
'/dev',
'/downloader',
'~ ^/error/.*\.(xml|phtml)$',
'/includes',
'/lib',
'/media/downloadable',
'/shell',
'/skin/frontend/rwd/default/scss',
'/frontend/rwd/enterprise/scss',
'/var',
'/.gitignore',
'/composer.json',
'/cron.php',
'/cron.sh',
'/index.php.sample',
'/install.php',
'/mage',
'/php.ini.sample',
'/RELEASE_NOTES.txt'
].each do |dir| %>
<Location <%= dir %>>
Order deny,allow
Deny from all
</Location>
<% end %>
<Directory <%= @params[:magento]['dir'] %>/media>
Options All -Indexes
<IfModule mod_php5.c>
php_flag engine 0
</IfModule>
AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi
Options -ExecCGI
<IfModule mod_rewrite.c>
############################################
## enable rewrites
Options +FollowSymLinks
RewriteEngine on
############################################
## never rewrite for existing files
RewriteCond %{REQUEST_FILENAME} !-f
############################################
## rewrite everything else to index.php
RewriteRule .* ../get.php [L]
</IfModule>
</Directory>
<Directory <%= @params[:magento]['dir'] %>/staging>
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<% if @params[:magento]['apache']['additional_config_path'] %>
# Include any additional configuration for the project
Include <%= @params[:magento]['apache']['additional_config_path'] %>/*.conf
<% end %>
</VirtualHost>