-
Notifications
You must be signed in to change notification settings - Fork 64
/
mediawiki-nginx.yml
1572 lines (1402 loc) · 61.8 KB
/
mediawiki-nginx.yml
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Single EC2 Running Mediawiki on Nginx, RDS Backed, Behind LB by Levon Becker v20170210-1430
Parameters:
# Ownership
Owner:
Type: String
Default: FirstName LastName
DeleteAfter:
Type: String
Default: 00/00/201x
# Network
VPC:
Type: AWS::EC2::VPC::Id
SubnetId:
Type: AWS::EC2::Subnet::Id
InternalAccessSecurityGroup:
Type: AWS::EC2::SecurityGroup::Id
RemoteSecurityGroup:
Type: AWS::EC2::SecurityGroup::Id
RdsSecurityGroup:
Type: AWS::EC2::SecurityGroup::Id
EfsSecurityGroup:
Type: AWS::EC2::SecurityGroup::Id
LbLanIp:
Type: String
Description: Load Balancer LAN IP for Reverse Proxy
Default: "10.0.0.1"
# DNS
HostedZoneId:
Type: String
Description: Route53 Hosted Zone ID (Z1234567890).
Default: Z1234567890
RecordName:
Type: String
Description: DNS Alias Record Name (web01.example.com)
Default: web01.example.com
# EFS Mount
EfsMountPoint:
Type: String
Default: /path/to/mount1
EfsFileSystemId:
Type: String
Default: fs-00000000
# Instance
KeyPairName:
Type: AWS::EC2::KeyPair::KeyName
InstanceType:
Type: String
AllowedValues:
- t2.nano
- t2.micro
- t2.small
- t2.medium
- m3.medium
- m4.large
- c3.medium
- c4.medium
Default: t2.small
# Database
DbHost:
Type: String
DbName:
Type: String
DbUser:
Type: String
DbPassword:
Type: String
NoEcho: 'true'
MinLength: '6'
AllowedPattern: "[a-zA-Z0-9!?]*"
ConstraintDescription: Must only contain upper and lowercase letters, numbers and contain a minimum of 6 characters
# MediaWiki
MediawikiMajorRelease:
Type: String
Default: 1
MediawikiMinorRelease:
Type: String
Default: 28
SiteTitle:
Type: String
SiteURL:
Type: String
Default: https://www.example.com
VirtaulServerNames:
Type: String
Description: Load Balancer Alias
Default: "example.com www.example.com"
ContactEmail:
Type: String
Default: first.last@domain.com
SecretKey:
Type: String
UpgradeKey:
Type: String
GoogleAnalyticsAccount:
Type: String
ReCaptchaSiteKey:
Type: String
ReCaptchaSecretKey:
Type: String
# Deployment
Environment:
Type: String
Default: 'dev'
AllowedValues:
- 'dev'
- 'prd'
S3ContentPath:
Type: String
Default: bucket-name
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
# Ownership
- Label:
default: Ownership
Parameters:
- Owner
- DeleteAfter
# Network
- Label:
default: Network
Parameters:
- VPC
- SubnetId
- SecurityGroup
- InternalAccessSecurityGroup
- RemoteSecurityGroup
- RdsSecurityGroup
- EfsSecurityGroup
- LbLanIp
# Instance Settings
- Label:
default: Instance
Parameters:
- KeyPairName
- InstanceType
# DNS
- Label:
default: DNS
Parameters:
- RecordName
- HostedZoneId
# EFS
- Label:
default: EFS
Parameters:
- EfsMountPoint
- EfsFileSystemId
# Database
- Label:
default: Database Config
Parameters:
- DbHost
- DbName
- DbUser
- DbPassword
# Mediawiki
- Label:
default: Mediawiki
Parameters:
- MediawikiMajorRelease
- MediawikiMinorRelease
- SiteTitle
- SiteURL
- VirtaulServerNames
- ContactEmail
- SecretKey
- UpgradeKey
- GoogleAnalyticsAccount
# Deployment
- Label:
default: Deployment
Parameters:
- Environment
- S3ContentPath
ParameterLabels:
# Ownership
Owner:
default: Team or Individual Owner
DeleteAfter:
default: Delete After Date
# Network
VPC:
default: VPC ID
SubnetId:
default: Subnet ID
InternalAccessSecurityGroup:
default: Internal Access Security Group
RemoteSecurityGroup:
default: Remote Security Group
RdsSecurityGroup:
default: RDS Security Group
EfsSecurityGroup:
default: EFS Security Group
LbLanIp:
default: Load Balancer LAN IP
# Instance Settings
KeyPairName:
default: EC2 Key Pair Name
InstanceType:
default: Instance Type
# DNS
RecordName:
default: Record Name
HostedZoneId:
default: Hosted Zone ID
# EFS
EfsMountPoint:
default: EFS Mount Point
EfsFileSystemId:
default: EFS File System Id
# Database
DbHost:
default: Database Host
DbName:
default: Database Name
DbUser:
default: Database User
DbPassword:
default: Database Password
# MediaWiki
MediawikiMajorRelease:
default: Mediawiki Major Release
MediawikiMinorRelease:
default: Mediawiki Minor Release
SiteTitle:
default: Site Title
SiteURL:
default: Site URL
VirtaulServerNames:
default: Virtual Server Names
ContactEmail:
default: Contact Email
SecretKey:
default: Secret Key
UpgradeKey:
default: Upgrade Key
GoogleAnalyticsAccount:
default: Google Analytics Account
# Deployment
Environment:
default: Environment
S3ContentPath:
default: "S3 Deploy Bucket Name"
Mappings:
RegionMap:
# Amazon Linux AMI 2016.09.0 was released on 2016-09-27
us-east-1:
InstanceStore: ami-de3860c9
EBS: ami-b73b63a0
us-west-2:
InstanceStore: ami-44c36524
EBS: ami-5ec1673e
us-west-1:
InstanceStore: ami-34e9a254
EBS: ami-23e8a343
eu-west-1:
InstanceStore: ami-d998d3aa
EBS: ami-9398d3e0
eu-central-1:
InstanceStore: ami-0f639b60
EBS: ami-f9619996
ap-southeast-1:
InstanceStore: ami-7a54f519
EBS: ami-b953f2da
ap-northeast-1:
InstanceStore: ami-0a12b16b
EBS: ami-0c11b26d
ap-northeast-2:
InstanceStore: ami-ba35e1d4
EBS: ami-983ce8f6
ap-southeast-2:
InstanceStore: ami-41754922
EBS: ami-db704cb8
sa-east-1:
InstanceStore: ami-59bd2135
EBS: ami-97831ffb
us-gov-west-1:
InstanceStore: ami-e0b10981
EBS: ami-7cb1091d
cn-north-1:
InstanceStore: ami-81eb3fec
EBS: ami-7c15c111
Resources:
# CloudWatch
CloudWatchLogsGroup:
Type: AWS::Logs::LogGroup
Properties:
LogGroupName: !Ref "AWS::StackName"
RetentionInDays: '30'
# IAM
IamRole:
Type: AWS::IAM::Role
Properties:
RoleName: !Ref AWS::StackName
ManagedPolicyArns:
- arn:aws:iam::aws:policy/ReadOnlyAccess
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Action:
- sts:AssumeRole
Path: "/"
IamPolicies:
Type: AWS::IAM::Policy
DependsOn: IamRole
Properties:
PolicyName: !Join [ '', [ !Ref "AWS::StackName", -instance-policy ] ]
Roles: [!Ref IamRole]
PolicyDocument:
Version: '2012-10-17'
Statement:
# Allow Full S3 Access
- Effect: Allow
Action:
- s3:*
Resource: "*"
# Allow Read/Write Route53 for Userdata Script DNS A Record Set
- Effect: Allow
Action:
- route53:ChangeResourceRecordSets
- route53:Get*
- route53:List*
Resource: "*"
# Allow Write CloudWatch Logs
- Effect: Allow
Action:
- cloudwatch:PutMetricData
Resource: "*"
- Effect: Allow
Action:
- logs:PutLogEvents
- logs:CreateLogStream
- logs:DescribeLogStreams
- logs:CreateLogGroup
Resource:
Fn::Join:
- ''
- - 'arn:aws:logs:'
- !Ref AWS::Region
- ":"
- !Ref AWS::AccountId
- ":log-group:"
- !Ref CloudWatchLogsGroup
- ":log-stream:*"
IamInstanceProfile:
Type: AWS::IAM::InstanceProfile
DependsOn: IamRole
Properties:
Path: "/"
Roles: [!Ref IamRole]
# Security Groups
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Allow Web Traffic to Instance
VpcId: !Ref VPC
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: 443
ToPort: 443
CidrIp: 0.0.0.0/0
SecurityGroupEgress:
- IpProtocol: "-1"
FromPort: "-1"
ToPort: "-1"
CidrIp: 0.0.0.0/0
Tags:
- Key: Name
Value: !Ref "AWS::StackName"
- Key: Owner
Value: !Ref Owner
- Key: DeleteAfter
Value: !Ref DeleteAfter
# EC2 Instance
EC2Instance:
Type: AWS::EC2::Instance
DependsOn:
- SecurityGroup
- IamInstanceProfile
Properties:
IamInstanceProfile: !Ref IamInstanceProfile
InstanceType: !Ref InstanceType
KeyName: !Ref KeyPairName
SubnetId: !Ref SubnetId
SecurityGroupIds:
- !Ref SecurityGroup
- !Ref InternalAccessSecurityGroup
- !Ref RemoteSecurityGroup
- !Ref RdsSecurityGroup
- !Ref EfsSecurityGroup
ImageId: !FindInMap [ RegionMap, !Ref "AWS::Region", EBS ]
Monitoring: false
BlockDeviceMappings:
- DeviceName: /dev/xvda
Ebs:
DeleteOnTermination: true
VolumeType: gp2
VolumeSize: 8
Tags:
- Key: Name
Value: !Ref "AWS::StackName"
- Key: Owner
Value: !Ref Owner
- Key: DeleteAfter
Value: !Ref DeleteAfter
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
yum update -y
yum install -y aws-cfn-bootstrap cloud-init aws-cli
/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region} --configsets ec2_setup
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region}
# CFN INIT
Metadata:
AWS::CloudFormation::Init:
configSets:
ec2_setup:
- config_cfn
- install_packages
- install_mediawiki
- setup_uploads_efs
- set_backlog_sockets
- install_mediawiki_extensions
- mediawiki_customizations
- config_mediawiki
- config_php_fpm
- start_services
- deploy_dns_update_script
- run_update_dns
- install_yum_cron
- setup_yum_cron
- warm_ebs
config_cfn:
files:
"/etc/cfn/cfn-hup.conf":
content: !Sub |
[main]
stack=${AWS::StackId}
region=${AWS::Region}
mode: '000400'
owner: root
group: root
"/etc/cfn/hooks.d/cfn-auto-reloader.conf":
content: !Sub |
[cfn-auto-reloader-hook]
triggers=post.update
path=Resources.EC2Instance.Metadata.AWS::CloudFormation::Init
action=/opt/aws/bin/cfn-init -v --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region} --configsets ec2_setup
runas=root
services:
sysvinit:
cfn-hup:
enabled: true
ensureRunning: true
files:
- /etc/cfn/cfn-hup.conf
- /etc/cfn/hooks.d/cfn-auto-reloader.conf
install_packages:
commands:
01_install_nginx:
command: "yum install -y git vim htop mlocate nginx mysql56 php70-fpm php70-mysqlnd php70-gd php70-mbstring php70-mcrypt php70-cli php70-common php70-enchant php70-gd php70-intl php70-jsonc php70-mbstring php70-mcrypt php70-mysqlnd php70-pdo php70-pecl-apcu php70-pecl-http php70-pecl-imagick php70-pecl-raphf php70-process php70-xml apr apr-util enchant ImageMagick json-c mysql56 nfs-utils openssl openssl-devel perl-core perl-CPAN perl-Crypt-SSLeay perl-DateTime perl-libwww-perl perl-Sys-Syslog"
install_mediawiki:
commands:
01_create_www:
command: "mkdir -p /var/www/html"
02_download_mediawiki:
cwd: /var/www/html
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/core.git"
03_rename_dir:
cwd: /var/www/html
command: "mv core mediawiki"
04_chmod_site:
cwd: /var/www/html
command: "chown -R nginx:nginx mediawiki"
setup_uploads_efs:
commands:
01_make_mount_dir:
cwd: /var/www/html
command: !Sub "mkdir -p ${EfsMountPoint}"
02_update_fstab:
cwd: /var/www/html
command: !Sub |
echo "${EfsFileSystemId}.efs.${AWS::Region}.amazonaws.com:/ ${EfsMountPoint} nfs4 nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 0 0" >> /etc/fstab
03_mount_efs:
command: "mount -a -t nfs4"
set_backlog_sockets:
commands:
01_set_somaxconn_in_memory:
cwd: /var/www/html
command: "sysctl -w net.core.somaxconn=1024"
02_set_somaxcoon_for_reboot:
cwd: /var/www/html
command: "echo 'net.core.somaxconn = 1024' >> /etc/sysctl.conf"
03_set_syncookies_in_memory:
cwd: /var/www/html
command: "sysctl -w net.ipv4.tcp_syncookies=4096"
04_set_syncookies_for_reboot:
cwd: /var/www/html
command: "echo 'net.ipv4.tcp_syncookies = 4096' >> /etc/sysctl.conf"
install_mediawiki_extensions:
commands:
001_MobileFrontend:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/MobileFrontend.git"
002_SyntaxHighlight_GeSHi:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/SyntaxHighlight_GeSHi.git"
003_UploadWizard:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/UploadWizard.git"
004_News:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/News.git"
005_MultiBoilerplate:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/MultiBoilerplate.git"
006_ReplaceText:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ReplaceText.git"
007_YouTube:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/YouTube.git"
008_AntiBot:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/AntiBot.git"
009_AntiSpoof:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/AntiSpoof.git"
010_SimpleAntiSpam:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/SimpleAntiSpam.git"
011_SpamBlacklist:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/SpamBlacklist.git"
012_googleAnalytics:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/googleAnalytics.git"
013_Mantle:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Mantle.git"
015_Cite:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Cite.git"
016_ConfirmEdit:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ConfirmEdit.git"
017_Gadgets:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Gadgets.git"
018_ImageMap:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ImageMap.git"
019_InputBox:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/InputBox.git"
020_Interwiki:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Interwiki.git"
021_LocalisationUpdate:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/LocalisationUpdate.git"
022_Nuke:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Nuke.git"
023_ParserFunctions:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/ParserFunctions.git"
024_PdfHandler:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/PdfHandler.git"
025_Poem:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Poem.git"
026_Renameuser:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Renameuser.git"
029_TitleBlacklist:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/TitleBlacklist.git"
030_WikiEditor:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/WikiEditor.git"
030b_Scribunto:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Scribunto.git"
030c_AutoSitemap:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "git clone https://github.com/bonusbits/AutoSitemap.git"
031_mkdir_HideNamespace:
cwd: /var/www/html/mediawiki/extensions
command: "mkdir HideNamespace"
032_HideNamespace:
cwd: /var/www/html/mediawiki/extensions
command: !Sub "aws s3 sync s3://${S3ContentPath}/HideNamespace/ HideNamespace/ --sse"
033_chmod_extensions:
cwd: /var/www/html/mediawiki
command: "chown -R nginx:nginx extensions"
034_vendor_clone_insteadof_composer:
cwd: /var/www/html/mediawiki
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/vendor.git"
035_chmod_vendor:
cwd: /var/www/html/mediawiki
command: "chown -R nginx:nginx vendor"
mediawiki_customizations:
commands:
001_download_vector_skin:
cwd: /var/www/html/mediawiki/skins
command: !Sub "git clone --branch REL${MediawikiMajorRelease}_${MediawikiMinorRelease} https://gerrit.wikimedia.org/r/p/mediawiki/skins/Vector.git"
002_chmod_vector:
cwd: /var/www/html/mediawiki/skins
command: "chown -R nginx:nginx Vector"
003_desktop_logo:
cwd: /var/www/html/mediawiki/images
command: !Sub "aws s3 cp s3://${S3ContentPath}/logo17_128x128.png desktop_logo.png --sse"
004_mobile_logo:
cwd: /var/www/html/mediawiki/images
command: !Sub "aws s3 cp s3://${S3ContentPath}/logo_mobile17.png mobile_logo.png --sse"
005_chmod_logos:
cwd: /var/www/html/mediawiki/images
command: "chown -R nginx:nginx *.png"
006_favicon:
cwd: /var/www/html/mediawiki
command: !Sub "aws s3 cp s3://${S3ContentPath}/favicon.ico . --sse"
007_chmod_favicon:
cwd: /var/www/html/mediawiki
command: "chown nginx:nginx favicon.ico"
008_adsense_vector:
cwd: /var/www/html/mediawiki/skins/Vector
command: !Sub "aws s3 cp s3://${S3ContentPath}/VectorTemplate.php . --sse"
009_chmod_vectortemplate:
cwd: /var/www/html/mediawiki/skins/Vector
command: "chown nginx:nginx VectorTemplate.php"
010_adsense_mobilefrontend:
cwd: /var/www/html/mediawiki/extensions/MobileFrontend/includes/skins
command: !Sub "aws s3 cp s3://${S3ContentPath}/MinervaTemplate.php . --sse"
011_chmod_mobilefrontend:
cwd: /var/www/html/mediawiki/extensions/MobileFrontend/includes/skins
command: "chown nginx:nginx MinervaTemplate.php"
#012_news_fix_underscores:
# cwd: /var/www/html/mediawiki/extensions/News
# command: !Sub "aws s3 cp s3://${S3ContentPath}/NewsRenderer.php . --sse"
#013_chmod_news:
# cwd: /var/www/html/mediawiki/extensions/News
# command: "chown nginx:nginx NewsRenderer.php"
config_mediawiki:
files:
"/etc/nginx/conf.d/mediawiki.conf":
content: !Sub |
server {
listen 80 backlog=1024;
set_real_ip_from ${LbLanIp};
real_ip_header X-Forwarded-For;
real_ip_recursive on;
server_name ${VirtaulServerNames};
root /var/www/html/mediawiki;
index index.php;
# client_max_body_size 24000M;
#access_log /var/log/nginx/mediawiki_access.log;
#error_log /var/log/nginx/mediawiki_error.log;
#error_log /var/log/nginx/medaiwiki_debug.log debug;
location / {
# Recognize if HTTPS Terminate Prior to Nginx Getting Hands on it
if ($http_x_forwarded_proto != 'https') {
rewrite ^ https://$host$request_uri? permanent;
}
try_files $uri $uri/ @handler;
# error_page 404 = @mediawiki;
}
# location @mediawiki {
# rewrite ^/wiki([^?]*)(?:\?(.*))? /index.php?title=$1&$2 last;
# }
location @handler {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /var/www/html/mediawiki/index.php;
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_NAME /index.php;
}
location ~ .php$ {
try_files $uri @handler;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/html/mediawiki$fastcgi_script_name;
include fastcgi_params;
}
# Exclude all access from the cache directory
location ^~ /cache/ { deny all; }
# Prevent access to any files starting with a dot, like .htaccess
# or text editor temp files
location ~ /\. { access_log off; log_not_found off; deny all; }
# Prevent access to any files starting with a dot, like .htaccess
# or text editor temp files
location ~ /\. { access_log off; log_not_found off; deny all; }
# Prevent access to any files starting with a $ (usually temp files)
location ~ ~$ { access_log off; log_not_found off; deny all; }
# Do not log access to robots.txt, to keep the logs cleaner
location = /robots.txt { access_log off; log_not_found off; }
# Do not log access to the favicon, to keep the logs cleaner
location = /favicon.ico { access_log off; log_not_found off; }
# Keep images and CSS around in browser cache for as long as possible,
# to cut down on server load
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
try_files $uri /index.php;
expires 7d;
log_not_found off;
}
# Exception for AutoSitemap sitemap.xml template
location = /extensions/AutoSitemap/sitemap.xsl { allow all; }
# Mark all of these directories as "deny all", which means that they cannot
# be explicitly accessed by clients. However, the web server can still use
# and serve the files inside of them. This keeps people from poking around
# in the wiki's deny alls.
location ^~ /bin/ { deny all; }
location ^~ /docs/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /maintenance/ { deny all; }
location ^~ /mw-config/ { deny all; } #Uncomment after installation
location ^~ /resources/lib/ { deny all; }
location ^~ /resources/src/ { deny all; }
location ^~ /resources/Resources.php { deny all; } # ResourcesOOUI.php Resources.php
location ^~ /resources/ResourcesOOUI.php { deny all; } # ResourcesOOUI.php Resources.php
location ^~ /serialized/ { deny all; }
location ^~ /tests/ { deny all; }
location ^~ /skins/ { deny all; }
location ^~ /vendor/ { deny all; }
# Force potentially-malicious files in the /images directory to be served
# with a text/plain mime type, to prevent them from being executed by
# the PHP handler
location ~* ^/images/.*.(html|htm|shtml|php)$ { types { } default_type text/plain; }
# Redirect all requests for unknown URLs out of images and back to the
# root index.php file
location ^~ /images/ { try_files $uri /index.php; }
# Deny direct access to uploads directory
location ~* /(?:uploads|files)/.*\.php$ { deny all; }
}
"/var/www/html/mediawiki/robots.txt":
mode: "000644"
owner: nginx
group: nginx
encoding: plain
content: !Sub |
User-agent: *
Disallow: /*.json
Disallow: /*.php
Disallow: /*.php5
Disallow: /cache/*
Disallow: /extensions/*
Disallow: /images/*
Disallow: /includes/*
Disallow: /index.php?*
Disallow: /maintenance/*
Disallow: /mw-config/*
Disallow: /resources/*
Disallow: /skins/*
Disallow: /uploads/*
Disallow: /vendor/*
Disallow: /wiki/Category:*
Disallow: /wiki/File:*
Disallow: /wiki/Help:*
Disallow: /wiki/Image:*
Disallow: /wiki/List:*
Disallow: /wiki/Manual:*
Disallow: /wiki/Module:*
Disallow: /wiki/MediaWiki:*
Disallow: /wiki/Project:*
Disallow: /wiki/Special:*
Disallow: /wiki/Template:*
Disallow: /wiki/User:*
"/var/www/html/mediawiki/LocalSettings.php":
mode: "000444"
owner: nginx
group: nginx
encoding: plain
content: !Sub |
<?php
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
## Debugging
#$wgShowExceptionDetails = true;
#$wgShowSQLErrors = true;
#$wgDebugDumpSql = true;
#$wgShowDBErrorBacktrace = true;
#$wgDebugLogFile = "/var/log/mediawiki.log";
## Web Settings
# $wgDisableOutputCompression = true;
$wgSitename = "${SiteTitle}";
$wgMetaNamespace = "${SiteTitle}";
$wgScriptPath = "";
$wgArticlePath = "/wiki/$1";
$wgUsePathInfo = true;
$wgScriptExtension = ".php";
$wgFavicon = "$wgScriptPath/favicon.ico";
$wgServer = "${SiteURL}";
$wgStylePath = "$wgScriptPath/skins";
$wgLogo = "$wgScriptPath/images/desktop_logo.png";
$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgEmergencyContact = "${ContactEmail}";
$wgPasswordSender = "${ContactEmail}";
$wgEnotifUserTalk = true; # UPO
$wgEnotifWatchlist = true; # UPO
$wgEmailAuthentication = true;
$wgExternalLinkTarget = '_blank';
$wgUniversalEditButton = true;
## Database Settings
$wgDBtype = "mysql";
$wgDBserver = "${DbHost}";
$wgDBname = "${DbName}";
$wgDBuser = "${DbUser}";
$wgDBpassword = "${DbPassword}";
$wgDBprefix = "";
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
$wgDBmysql5 = false;
## Cache and Uploads
$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = array();
$wgCacheDirectory = "$IP/cache";
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgUseInstantCommons = true;
$wgShellLocale = "en_US.utf8";
$wgHashedUploadDirectory = false;
## Site Settings
$wgLanguageCode = "en";
$wgSecretKey = "${SecretKey}";
$wgUpgradeKey = "${UpgradeKey}";
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "http://www.gnu.org/copyleft/fdl.html";
$wgRightsText = "GNU Free Documentation License 1.3 or later";
$wgRightsIcon = "{$wgResourceBasePath}/resources/assets/licenses/gnu-fdl.png";
$wgDiff3 = "/usr/bin/diff3";
## Permissions
$wgGroupPermissions['*']['createaccount'] = false;
$wgGroupPermissions['*']['read'] = true;
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['createpage'] = false;
$wgGroupPermissions['*']['createtalk'] = false;
$wgGroupPermissions['*']['writeapi'] = false;
## Skin
require_once "$IP/skins/Vector/Vector.php";
$wgDefaultSkin = "vector";
## Base Extensions
require_once "$IP/extensions/Cite/Cite.php";
require_once "$IP/extensions/ConfirmEdit/ConfirmEdit.php";
require_once "$IP/extensions/Gadgets/Gadgets.php";
require_once "$IP/extensions/ImageMap/ImageMap.php";
require_once "$IP/extensions/InputBox/InputBox.php";
require_once "$IP/extensions/Interwiki/Interwiki.php";
require_once "$IP/extensions/LocalisationUpdate/LocalisationUpdate.php";
require_once "$IP/extensions/Nuke/Nuke.php";
require_once "$IP/extensions/ParserFunctions/ParserFunctions.php";
require_once "$IP/extensions/PdfHandler/PdfHandler.php";
require_once "$IP/extensions/Poem/Poem.php";
require_once "$IP/extensions/Renameuser/Renameuser.php";
require_once "$IP/extensions/SpamBlacklist/SpamBlacklist.php";
require_once "$IP/extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php";
require_once "$IP/extensions/TitleBlacklist/TitleBlacklist.php";
require_once "$IP/extensions/WikiEditor/WikiEditor.php";
# End of automatically generated settings.
# Add more configuration options below.
##########################################
# START: UNC Links
##########################################
## Enable UNC Links
# http://www.mediawiki.org/wiki/UNC_links
#array_push($wgUrlProtocols, "file://");
##########################################
# END: UNC Links
##########################################
##########################################
# BEGIN ConfirmEdit - ReCaptcha
##########################################
#wfLoadExtensions( array( 'ConfirmEdit', 'ConfirmEdit/ReCaptchaNoCaptcha' ) );
require_once "$IP/extensions/ConfirmEdit/ReCaptchaNoCaptcha.php";
$wgCaptchaClass = 'ReCaptchaNoCaptcha';
$wgReCaptchaSiteKey = '${ReCaptchaSiteKey}';
$wgReCaptchaSecretKey = '${ReCaptchaSecretKey}';
$wgGroupPermissions['*' ]['skipcaptcha'] = false;
$wgGroupPermissions['user' ]['skipcaptcha'] = false;
$wgGroupPermissions['autoconfirmed']['skipcaptcha'] = true;
$wgGroupPermissions['bot' ]['skipcaptcha'] = true; // registered bots
$wgGroupPermissions['sysop' ]['skipcaptcha'] = true;
$wgCaptchaTriggers['edit'] = true;
$wgCaptchaTriggers['create'] = true;
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin'] = true;
$wgCaptchaTriggers['contactpage'] = true; // Adds reCAPTCHA to the contact page if created
##########################################
# END ConfirmEdit - ReCaptcha
##########################################
##########################################
# BEGIN LOAD BALANCER SETTINGS
##########################################
$wgUsedPrivateIPs = true;
##########################################
# END LOAD BALANCER SETTINGS
##########################################
###################################
# BEGIN: Memory Settings
##################################
//Maximum amount of virtual memory available to shell processes under linux, in KB.
//http://www.mediawiki.org/wiki/Manual:$wgMaxShellMemory
//Default = 102400
$wgMaxShellMemory = 102400*64;
//Maximum CPU time in seconds for shell processes under Linux.
//http://www.mediawiki.org/wiki/Manual:$wgMaxShellTime
//Default = 180 seconds
$wgMaxShellTime = 500;
// Maximum file size created by shell processes under linux, in KB
// ImageMagick convert for example can be fairly hungry for scratch space
// http://www.mediawiki.org/wiki/Manual:$wgMaxShellFileSize
// Default = 102400
$wgMaxShellFileSize = 102400*64;