-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
wpsetup.inc
3488 lines (3103 loc) · 167 KB
/
wpsetup.inc
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
wpinstall() {
if [ ! -f /usr/bin/wp ]; then
cecho "------------------------------------------------------------" $boldgreen
cecho "Installing wpcli.sh" $boldyellow
cecho "------------------------------------------------------------" $boldgreen
if [ -d "${SCRIPT_DIR}/addons" ]; then
cd ${SCRIPT_DIR}/addons
fi
chmod +x wpcli.sh
./wpcli.sh install
else
cecho "------------------------------------------------------------" $boldgreen
cecho "Update wp-cli tool" $boldyellow
cecho "------------------------------------------------------------" $boldgreen
if [ -d "${SCRIPT_DIR}/addons" ]; then
cd ${SCRIPT_DIR}/addons
fi
chmod +x wpcli.sh
./wpcli.sh update
fi
}
installredisserver() {
if [[ "$(ps -C redis-server | grep redis-server >/dev/null 2>&1; echo $?)" != '0' ]]; then
echo
echo "Install & Setup Redis Server from REMI YUM Repo"
echo
yum -y install redis --enablerepo=remi --disableplugin=priorities
chkconfig redis on
if [[ -z "$(grep '^vm.overcommit_memory' /etc/sysctl.conf)" ]]; then
echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf
sysctl -p
fi
if [ -f /etc/redis.conf ]; then
if [[ -z "$(grep '^maxmemory 111mb' /etc/redis.conf)" ]]; then
echo "maxmemory 111mb" >> /etc/redis.conf
grep '^maxmemory 111mb' /etc/redis.conf
fi
if [[ -z "$(grep '^maxmemory-policy allkeys-lru' /etc/redis.conf)" ]]; then
echo "maxmemory-policy allkeys-lru" >> /etc/redis.conf
grep '^maxmemory-policy allkeys-lru' /etc/redis.conf
fi
if [[ -z "$(grep '^maxmemory-samples 10' /etc/redis.conf)" ]]; then
echo "maxmemory-samples 10" >> /etc/redis.conf
grep '^maxmemory-samples 10' /etc/redis.conf
fi
fi
service redis restart
echo
echo "Redis server installed with config file at /etc/redis.conf"
echo
fi
}
dbsetup() {
SALT=$(/usr/bin/openssl rand -base64 14 | tr -dc 'a-zA-Z0-9')
DBN=$RANDOM
DBNB=$RANDOM
DBNC=$RANDOM
DBND=$RANDOM
DBNE=$RANDOM
DB="wp${DBNE}${DBN}db_${DBND}"
DBUSER="wpdb${DBND}u${DBNB}"
DBPASS="wpdb${SALT}p${DBNC}"
mysqladmin create $DB
mysql -e "CREATE USER $DBUSER@'localhost' IDENTIFIED BY '$DBPASS';"
mysql -e "GRANT index, select, insert, delete, update, create, drop, alter, create temporary tables, execute, lock tables, create view, show view, create routine, alter routine, trigger ON ${DB}.* TO ${DBUSER}@'localhost'; FLUSH PRIVILEGES;"
}
wpinfo_notice() {
cecho "---------------------------------------------------------------" $boldyellow
cecho "Important Information" $boldgreen
cecho "---------------------------------------------------------------" $boldyellow
echo
echo "You are about to create an Wordpress based Nginx vhost site with"
echo "or without HTTPS/SSL support."
echo "Also read the continually updated Getting Started Guide"
echo "at centminmod.com/getstarted.html if you haven't already"
cecho "---------------------------------------------------------------" $boldyellow
echo "403 Permission denied message handling"
echo "if after vhost site setup you encounter 403 permission denied errors,"
echo "check https://community.centminmod.com/threads/11215/ to see if your"
echo "site needs tools/autoprotect.sh tweaking & whitelisting"
cecho "---------------------------------------------------------------" $boldyellow
if [[ "$LETSENCRYPT_DETECT" != [yY] ]]; then
echo "[ LETSENCRYPT_DETECT is not enabled ]"
echo "Ignore this message if you do not want HTTPS based web site otherwise"
echo "read below carefully."
echo
echo "Free letsencrypt SSL certificates integration is in beta testing if"
echo "you want to obtain free letsencrypt SSL certificate for HTTPS site,"
echo "you will need to manually enable LETSENCRYPT_DETECT='y' outlined"
echo "at https://centminmod.com/acmetool so exit this vhost routine first"
echo "set LETSENCRYPT_DETECT='y' and update domain DNS A record first"
echo "then re-run vhost site creation menu option"
cecho "---------------------------------------------------------------" $boldyellow
fi
# check mysql server is running
mysqladmin -s ping >/dev/null 2>&1
CHECKMYSQL_PING=$?
if [[ "$CHECKMYSQL_PING" -ne '0' ]]; then
echo
echo "!! Error: MariaDB MySQL Server is not running !!"
echo "Please make sure MariaDB MySQL Server is running first"
echo "aborting centmin.sh menu option 22 run..."
exit
fi
echo
read -ep "Do you want to continue with Nginx vhost site creation ? [y/n] " dovhost_continue
echo
if [[ "$dovhost_continue" != [yY] ]]; then
echo "aborting Wordpress + Nginx vhost setup..."
exit
fi
}
sslvhost() {
cecho "---------------------------------------------------------------" $boldyellow
cecho "SSL Vhost Setup..." $boldgreen
cecho "---------------------------------------------------------------" $boldyellow
echo ""
if [[ "$(nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]] && [[ "$(nginx -V 2>&1 | grep -Eo 'with-http_spdy_module')" = 'with-http_spdy_module' ]]; then
HTTPTWO=y
LISTENOPT='ssl spdy http2'
COMP_HEADER='spdy_headers_comp 5'
SPDY_HEADER='add_header Alternate-Protocol 443:npn-spdy/3;'
# removed in nginx 1.19.7+
# http://hg.nginx.org/nginx/rev/827202ca1269
# http://hg.nginx.org/nginx/rev/f790816a0e87
#HTTPTWO_MAXFIELDSIZE='http2_max_field_size 16k;'
#HTTPTWO_MAXHEADERSIZE='http2_max_header_size 32k;'
#HTTPTWO_MAXREQUESTS='http2_max_requests 50000;'
elif [[ "$(nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then
HTTPTWO=y
if [[ "$(grep -rn listen /usr/local/nginx/conf/conf.d/*.conf | grep -v '#' | grep 443 | grep ' ssl' | grep ' http2' | grep -o reuseport )" != 'reuseport' ]]; then
# check if reuseport is supported for listen 443 port - only needs to be added once globally for all nginx vhosts
NGXVHOST_CHECKREUSEPORT=$(grep --color -Ro SO_REUSEPORT /usr/src/kernels/* | head -n1 | awk -F ":" '{print $2}')
if [[ "$NGXVHOST_CHECKREUSEPORT" = 'SO_REUSEPORT' ]]; then
ADD_REUSEPORT=' reuseport'
else
ADD_REUSEPORT=""
fi
LISTENOPT="ssl http2${ADD_REUSEPORT}"
else
LISTENOPT='ssl http2'
fi
COMP_HEADER='#spdy_headers_comp 5'
SPDY_HEADER='#add_header Alternate-Protocol 443:npn-spdy/3;'
# removed in nginx 1.19.7+
# http://hg.nginx.org/nginx/rev/827202ca1269
# http://hg.nginx.org/nginx/rev/f790816a0e87
#HTTPTWO_MAXFIELDSIZE='http2_max_field_size 16k;'
#HTTPTWO_MAXHEADERSIZE='http2_max_header_size 32k;'
#HTTPTWO_MAXREQUESTS='http2_max_requests 50000;'
else
HTTPTWO=y
LISTENOPT='ssl http2'
COMP_HEADER='#spdy_headers_comp 5'
SPDY_HEADER='#add_header Alternate-Protocol 443:npn-spdy/3;'
fi
if [ ! -f /usr/local/nginx/conf/ssl ]; then
mkdir -p /usr/local/nginx/conf/ssl
fi
if [ ! -d /usr/local/nginx/conf/ssl/${vhostname} ]; then
mkdir -p /usr/local/nginx/conf/ssl/${vhostname}
fi
# cloudflare authenticated origin pull cert
# setup https://community.centminmod.com/threads/13847/
if [ ! -d /usr/local/nginx/conf/ssl/cloudflare/${vhostname} ]; then
mkdir -p /usr/local/nginx/conf/ssl/cloudflare/${vhostname}
wget${ipv_forceopt_wget} $CLOUDFLARE_AUTHORIGINPULLCERT -O /usr/local/nginx/conf/ssl/cloudflare/${vhostname}/origin.crt
elif [ -d /usr/local/nginx/conf/ssl/cloudflare/${vhostname} ]; then
wget${ipv_forceopt_wget} $CLOUDFLARE_AUTHORIGINPULLCERT -O /usr/local/nginx/conf/ssl/cloudflare/${vhostname}/origin.crt
fi
if [ ! -f /usr/local/nginx/conf/ssl_include.conf ]; then
cat > "/usr/local/nginx/conf/ssl_include.conf"<<EVS
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 60m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
EVS
fi
cd /usr/local/nginx/conf/ssl/${vhostname}
cecho "---------------------------------------------------------------" $boldyellow
cecho "Generating self signed SSL certificate..." $boldgreen
cecho "CSR file can also be used to be submitted for paid SSL certificates" $boldgreen
cecho "If using for paid SSL certificates be sure to keep both private key and CSR safe" $boldgreen
cecho "creating CSR File: ${vhostname}.csr" $boldgreen
cecho "creating private key: ${vhostname}.key" $boldgreen
cecho "creating self-signed SSL certificate: ${vhostname}.crt" $boldgreen
sleep 9
if [[ -z "$SELFSIGNEDSSL_O" ]]; then
SELFSIGNEDSSL_O="$vhostname"
else
SELFSIGNEDSSL_O="$SELFSIGNEDSSL_O"
fi
if [[ -z "$SELFSIGNEDSSL_OU" ]]; then
SELFSIGNEDSSL_OU="$vhostname"
else
SELFSIGNEDSSL_OU="$SELFSIGNEDSSL_OU"
fi
if [[ "$SELFSIGNEDSSL_ECDSA" = [yY] ]]; then
# self-signed ssl cert with SANs for ECDSA
cat > /tmp/reqecc.cnf <<EOF
[req]
default_bits = 2048
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
C = ${SELFSIGNEDSSL_C}
ST = ${SELFSIGNEDSSL_ST}
L = ${SELFSIGNEDSSL_L}
O = ${vhostname}
OU = ${vhostname}
CN = ${vhostname}
[v3_req]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = ${vhostname}
DNS.2 = www.${vhostname}
EOF
cat > /tmp/v3extecc.cnf <<EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = ${vhostname}
DNS.2 = www.${vhostname}
EOF
openssl ecparam -out ${vhostname}.key -name prime256v1 -genkey
openssl req -new -sha256 -key ${vhostname}.key -nodes -out ${vhostname}.csr -config /tmp/reqecc.cnf
openssl x509 -req -days 36500 -sha256 -in ${vhostname}.csr -signkey ${vhostname}.key -out ${vhostname}.crt -extfile /tmp/v3extecc.cnf
openssl x509 -noout -text < ${vhostname}.crt
rm -f /tmp/reqecc.cnf
rm -f /tmp/v3extecc.cnf
else
# self-signed ssl cert with SANs
cat > /tmp/req.cnf <<EOF
[req]
default_bits = 2048
distinguished_name = req_distinguished_name
req_extensions = v3_req
prompt = no
[req_distinguished_name]
C = ${SELFSIGNEDSSL_C}
ST = ${SELFSIGNEDSSL_ST}
L = ${SELFSIGNEDSSL_L}
O = ${vhostname}
OU = ${vhostname}
CN = ${vhostname}
[v3_req]
keyUsage = keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = ${vhostname}
DNS.2 = www.${vhostname}
EOF
cat > /tmp/v3ext.cnf <<EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = ${vhostname}
DNS.2 = www.${vhostname}
EOF
echo
cat /tmp/req.cnf
echo
cat /tmp/v3ext.cnf
echo
openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${vhostname}.csr -keyout ${vhostname}.key -config /tmp/req.cnf
# openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${vhostname}.csr -keyout ${vhostname}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${vhostname}/OU=${vhostname}/CN=${vhostname}"
openssl req -noout -text -in ${vhostname}.csr | grep DNS
openssl x509 -req -days 36500 -sha256 -in ${vhostname}.csr -signkey ${vhostname}.key -out ${vhostname}.crt -extfile /tmp/v3ext.cnf
# openssl req -x509 -nodes -days 36500 -sha256 -newkey rsa:2048 -keyout ${vhostname}.key -out ${vhostname}.crt -config /tmp/req.cnf
rm -f /tmp/req.cnf
rm -f /tmp/v3ext.cnf
fi
if [[ ! -f "$(find /usr/local/nginx/conf/ssl -type f -name "dhparam.pem" | head -n1)" ]]; then
echo
cecho "---------------------------------------------------------------" $boldyellow
cecho "Generating dhparam.pem file - can take a few minutes..." $boldgreen
dhparamstarttime=$(TZ=UTC date +%s.%N)
openssl dhparam -out dhparam.pem 2048
dhparamendtime=$(TZ=UTC date +%s.%N)
DHPARAMTIME=$(echo "$dhparamendtime-$dhparamstarttime"|bc)
cecho "dhparam file generation time: $DHPARAMTIME" $boldyellow
else
echo
cecho "---------------------------------------------------------------" $boldyellow
cecho "Copy/setup dhparam.pem file..." $boldgreen
cp -a "$(find /usr/local/nginx/conf/ssl -type f -name "dhparam.pem" | head -n1)" .
fi
}
wpacctsetup() {
PUREUSER=nginx
PUREGROUP=nginx
if [ "$SECOND_IP" ]; then
CNIP="$SECOND_IP"
else
CNIP=$(curl -${ipv_forceopt}s https://ipinfo.io/ip)
fi
pureftpinstall
# Support secondary dedicated IP configuration for centmin mod
# nginx vhost generator, so out of the box, new nginx vhosts
# generated will use the defined SECOND_IP=111.222.333.444 where
# the IP is a secondary IP addressed added to the server.
# You define SECOND_IP variable is centmin mod persistent config
# file outlined at https://centminmod.com/upgrade.html#persistent
# you manually creat the file at /etc/centminmod/custom_config.inc
# and add SECOND_IP=yoursecondary_IPaddress variable to it which
# will be registered with nginx vhost generator routine so that
# any new nginx vhosts created via centmin.sh menu option 2 or
# /usr/bin/nv or centmin.sh menu option 22, will have pre-defined
# SECOND_IP ip address set in the nginx vhost's listen directive
if [[ -z "$SECOND_IP" ]]; then
DEDI_IP=""
DEDI_LISTEN=""
elif [[ "$SECOND_IP" ]]; then
DEDI_IP=$(echo $(echo ${SECOND_IP}:))
DEDI_LISTEN="listen ${DEDI_IP}80;"
fi
wpinstall
WPSALT=$(/usr/bin/openssl rand -base64 21 | tr -dc 'a-zA-Z0-9')
WPSALTB=$(/usr/bin/openssl rand -base64 14 | tr -dc 'a-zA-Z0-9')
WPN=$RANDOM
WPNB=$RANDOM
WPADMINUSER="z${WPSALT}wp${WPNB}"
WPADMINUSER=$(echo $WPADMINUSER | sed -e 's|\/||g' -e 's|\+||g')
WPADMINPASS="z${WPSALTB}wps${WPN}"
WPADMINPASS=$(echo $WPADMINPASS | sed -e 's|\/||g' -e 's|\+||g')
if [ ! -d /root/tools ]; then
mkdir -p /root/tools
fi
echo
cecho "-------------------------------------------------------------" $boldyellow
cecho "Setup full Nginx vhost + Wordpress + WP Plugins" $boldgreen
cecho "-------------------------------------------------------------" $boldyellow
echo
wpinfo_notice
read -ep "Enter vhost domain name you want to add (without www. prefix): " vhostname
# if checkidn_vhost = 0 then internationalized domain name
checkidn_vhost=$(echo $vhostname | idn | grep '^xn--' >/dev/null 2>&1; echo $?)
if [[ "$checkidn_vhost" = '0' ]]; then
vhostname=$(echo $vhostname | idn)
fi
# check to make sure you don't add a domain name vhost that matches
# your server main hostname setup in server_name within main hostname
# nginx vhost at /usr/local/nginx/conf/conf.d/virtual.conf
if [ -f /usr/local/nginx/conf/conf.d/virtual.conf ]; then
CHECK_MAINHOSTNAME=$(awk '/server_name/ {print $2}' /usr/local/nginx/conf/conf.d/virtual.conf | sed -e 's|;||')
if [[ "${CHECK_MAINHOSTNAME}" = "${vhostname}" ]]; then
echo
echo " Error: $vhostname is already setup for server main hostname"
echo " at /usr/local/nginx/conf/conf.d/virtual.conf"
echo " It is important that main server hostname be setup correctly"
echo
echo " As per Getting Started Guide Step 1 centminmod.com/getstarted.html"
echo " The server main hostname needs to be unique. So please setup"
echo " the main server name vhost properly first as per Step 1 of guide."
echo
echo " Aborting nginx vhost creation..."
echo
exit 1
fi
fi
TESTVHOST=$(echo $vhostname | grep '\/')
while [[ "$TESTVHOST" ]]; do
echo "!! only domain.com or subdomain.domain.com supported !!"
echo " subdirectory is not supported right now"
read -ep "re-enter vhost domain name you want to add (without www. prefix): " vhostname
TESTVHOST=$(echo $vhostname | grep '\/')
echo
done
if [[ "$NGINX_VHOSTSSL" = [yY] ]]; then
echo
read -ep "Create a self-signed SSL certificate Nginx vhost? [y/n]: " vhostssl
if [[ -f "${SCRIPT_DIR}/addons/acmetool.sh" && "$LETSENCRYPT_DETECT" = [yY] ]]; then
read -ep "Get Letsencrypt SSL certificate Nginx vhost? [y/n]: " vhostssl_le
if [[ "$vhostssl_le" = [yY] ]]; then
echo
echo "You have 4 options: "
echo "1. issue staging test cert with HTTP + HTTPS (untrusted)"
echo "2. issue staging test cert with HTTPS default (untrusted)"
echo "3. issue live cert with HTTP + HTTPS (trusted)"
echo "4. issue live cert with HTTPS default (trusted)"
read -ep "Enter option number 1-4: " vhostssl_opt
if [[ "$vhostssl_opt" = '1' ]]; then
vhostssl='le'
elif [[ "$vhostssl_opt" = '2' ]]; then
vhostssl='led'
wpcli_ssldefault=1
elif [[ "$vhostssl_opt" = '3' ]]; then
vhostssl='lelive'
elif [[ "$vhostssl_opt" = '4' ]]; then
vhostssl='lelived'
wpcli_ssldefault=1
else
vhostssl=invalidopt
fi
echo
if [[ "$vhostssl_opt" -eq '2' || "$vhostssl_opt" -eq '4' ]] && [[ "$ISCF_ACHECK" = 'Cloudflare' || "$ISCF_ACHECK" = 'cloudflare' ]]; then
echo "If using Cloudflare in front of site, disable CF option for"
echo "Always Use HTTPS in CF Dashboard Crypto Tab as Nginx will do"
echo "the non-https to https redirect on this end and not require"
echo "Cloudflare's Always Use HTTPS. If enabled it will cause the"
echo "error message: too many redirects"
echo
echo "Also change Cloudflare Flexible SSL to Full SSL non-strict mode"
echo
sleep 1
fi
fi # vhostssl_le
fi
fi
if [[ "$vhostssl" = 'invalidopt' ]]; then
echo
echo "error: you entered invalid option = $vhostssl_opt"
echo "aborting run..."
exit 1
fi
echo "Theme Setup: "
read -ep "Install CyberChimps Responsive Theme (cyberchimps.com/responsive-theme/) [y/n]: " -i n responsivetheme
echo
echo "Wordpress Setup: "
echo
echo "Not a fan of Gutenberg Editor ? You can switch to Classic Editor"
echo "If you run into Gutenberg Editor issues, you can later switch to"
echo "the Classic Editor https://wordpress.org/plugins/classic-editor/"
read -ep "Install Classic Editor Wordpress Plugin ? [y/n]: " -i y wpclassic_editor
echo
echo "Autoptimize WP Plugin is installed by default. Do you want to install"
echo "companion Autoptimize Gzip Plugin to precompresses js/css optimized files"
echo "details at https://community.centminmod.com/threads/15314/"
read -ep "Install Autoptimize Gzip Companion Wordpress Plugin ? [y/n]: " -i y wpautoptimize_gzip
if [[ "$wpautoptimize_gzip" = [yY] ]]; then
WP_AUTOPTIMIZE_GZIP='y'
fi
echo
echo "Google Native LazyLoad Plugin https://wordpress.org/plugins/native-lazyload/"
read -ep "Install Google Native LazyLoad Plugin ? [y/n]: " -i y wp_google_lazyload
echo
read -ep "Set custom WP Admin Display Name ? [y/n]: " setdisplayname
if [[ "$setdisplayname" = [yY] ]]; then
read -ep "Enter Custom WP Admin Display Name: " displayname
WPADMIN_DISPLAYNAME=$displayname
fi
read -ep "Install Wordpress in subdirectory /blog ? [y/n]: " wpsubdirinstall
if [[ "$wpsubdirinstall" = [yY] ]]; then
SUBDIR_INSTALL=y
read -ep "Enter subdirectory name i.e. /blog enter = blog ? : " wpsubdir_value
WPSUBDIR="/$wpsubdir_value"
SUBDIR_INCLUDE="include /usr/local/nginx/conf/wpincludes/${vhostname}/wpsecure_${vhostname}.conf;"
NONSUBDIR_INCLUDE=""
elif [[ "$wpsubdirinstall" != [yY] ]]; then
SUBDIR_INSTALL=n
WPSUBDIR=""
SUBDIR_INCLUDE=""
NONSUBDIR_INCLUDE="include /usr/local/nginx/conf/wpincludes/${vhostname}/wpsecure_${vhostname}.conf;"
fi
read -ep "Disable Auto Generated WP Admin Username / Password ? [y/n]: " disableautogen
read -ep "Disable wp-login.php password protection ? (less security) [y/n]: " disablepwdprotect
if [[ "$disableautogen" = [yY] ]]; then
if [ ! -f /usr/sbin/cracklib-check ]; then
yum -y -q install cracklib
fi
echo
cecho "--------------------------" $boldgreen
cecho "!! Security Note !!" $boldyellow
cecho "--------------------------" $boldgreen
cecho "Please choose a stronger Username/Password Combination" $boldyellow
echo
read -ep "Enter desired WP Admin Username: " WPADMINUSER
read -ep "Enter desired WP Admin Password: " WPADMINPASS
CHECKWPADMINPASSWD="$(cracklib-check <<<"$WPADMINPASS")"
okay="$(awk -F': ' '{ print $2}' <<<"$CHECKWPADMINPASSWD")"
while [[ "$okay" != "OK" ]]; do
cecho "!! password strength not strong enough !! " $boldyellow
cecho "!! do not use common dictionary words !! " $boldyellow
cecho "!! do not use short passwords !! " $boldyellow
cecho "!! do not use simplistic passwords !! " $boldyellow
echo
read -ep "Re-Enter desired WP Admin Password: " WPADMINPASS
CHECKWPADMINPASSWD="$(cracklib-check <<<"$WPADMINPASS")"
okay="$(awk -F': ' '{ print $2}' <<<"$CHECKWPADMINPASSWD")"
done
fi
read -ep "Enter email address for Admin User for Wordpress Installation: " WPADMINEMAIL
# check if nginx server is compiled with default redis nginx modules,
# otherwise hide redis cache option if nginx server is missing
# required redis related nginx modules
CHECKFOR_REDISMODULES=$(nginx -V 2>&1 | egrep -o 'ngx_http_redis|redis2-nginx-module|ngx_cache_purge|set-misc-nginx-module' | xargs)
if [[ "$(echo $CHECKFOR_REDISMODULES | grep -o 'ngx_cache_purge')" = 'ngx_cache_purge' ]] && [[ "$(echo $CHECKFOR_REDISMODULES | grep -o 'set-misc-nginx-module')" = 'set-misc-nginx-module' ]] && [[ "$(echo $CHECKFOR_REDISMODULES | grep -o 'redis2-nginx-module')" = 'redis2-nginx-module' ]] && [[ "$(echo $CHECKFOR_REDISMODULES | grep -o 'ngx_http_redis')" = 'ngx_http_redis' ]]; then
redis_ngx_exists='y'
else
redis_ngx_exists='n'
fi
echo
cecho "Default is to install KeyCDN WP Cache Enabler Plugin" $boldyellow
cecho "as it's more stable and reliable than WP Super Cache." $boldyellow
if [[ "$redis_ngx_exists" = [yY] ]]; then
cecho "Redis cache may have issues with caching due to long 6hr cache TTL" $boldyellow
else
cecho "!! Redis cache not available - no redis nginx modules detected !!" $boldyellow
fi
cecho "You can select which caching method to use below:" $boldyellow
echo
cecho "--------------------------------------------------------" $boldyellow
cecho " Wordpress Caching " $boldgreen
cecho "--------------------------------------------------------" $boldyellow
if [[ "$WP_FASTCGI_CACHE" = [yY] ]]; then
if [[ "$redis_ngx_exists" = [yY] ]]; then
PS3='--------------------------------------------------------
Enter option [ 1 - 4 ] '
select_wpcache_opts=("KeyCDN Cache Enabler" "Redis Nginx Level Caching" "Wordpress Super Cache" "Fastcgi_cache (PHP-FPM)")
else
PS3='--------------------------------------------------------
Enter option [ 1 - 3 ] '
select_wpcache_opts=("KeyCDN Cache Enabler" "Wordpress Super Cache" "Fastcgi_cache (PHP-FPM)")
fi
elif [[ "$redis_ngx_exists" = [yY] ]]; then
PS3='--------------------------------------------------------
Enter option [ 1 - 3 ] '
select_wpcache_opts=("KeyCDN Cache Enabler" "Redis Nginx Level Caching" "Wordpress Super Cache")
else
PS3='--------------------------------------------------------
Enter option [ 1 - 2 ] '
select_wpcache_opts=("KeyCDN Cache Enabler" "Wordpress Super Cache")
fi
select optwp in "${select_wpcache_opts[@]}"; do
case $optwp in
"KeyCDN Cache Enabler" )
wpscache='n'
wpcache_option=$REPLY
echo
echo "you selected option $wpcache_option (KeyCDN Cache Enabler) [wpscache=$wpscache]"
echo
break
;;
"Redis Nginx Level Caching" )
wpscache='redis'
wpcache_option=$REPLY
echo
echo "you selected option $wpcache_option (Redis Nginx Level Cache) [wpscache=$wpscache]"
echo
break
;;
"Wordpress Super Cache" )
wpscache='y'
wpcache_option=$REPLY
echo
echo "you selected option $wpcache_option (Wordpress Super Cache) [wpscache=$wpscache]"
echo
break
;;
"Fastcgi_cache (PHP-FPM)" )
if [[ "$redis_ngx_exists" = [yY] && "$WP_FASTCGI_CACHE" = [yY] ]]; then
wpscache='fastcgicache'
elif [[ "$redis_ngx_exists" = [nN] && "$WP_FASTCGI_CACHE" = [yY] ]]; then
wpscache='fastcgicache'
else
wpscache='n'
fi
wpcache_option=$REPLY
echo
echo "you selected option $wpcache_option (Fastcgi_cache PHP-FPM) [wpscache=$wpscache]"
echo
break
;;
* )
echo
if [[ "$WP_FASTCGI_CACHE" = [yY] ]]; then
if [[ "$redis_ngx_exists" = [yY] ]]; then
echo "Valid options are 1 - 4"
else
echo "Valid options are 1 - 3"
fi
elif [[ "$redis_ngx_exists" = [yY] ]]; then
echo "Valid options are 1 - 3"
else
echo "Valid options are 1 - 2"
fi
echo
;;
esac
done
TESTEMAIL=$(echo "${WPADMINEMAIL}" | grep '^[a-zA-Z0-9._%+-]*@[a-zA-Z0-9-]*[\.[a-zA-Z0-9]*]*[a-zA-Z0-9]$')
# echo "$TESTEMAIL"
while [[ "$TESTEMAIL" = "" ]]; do
echo
echo "!! make sure email address is valid and typed correctly !!"
read -ep "Enter email address for Wordpress Installation: " WPADMINEMAIL
TESTEMAIL=$(echo "${WPADMINEMAIL}" | grep '^[a-zA-Z0-9._%+-]*@[a-zA-Z0-9-]*[\.[a-zA-Z0-9]*]*[a-zA-Z0-9]$')
echo
done
if [[ "$PUREFTPD_DISABLED" = [nN] ]]; then
if [ ! -f /usr/sbin/cracklib-check ]; then
yum -y -q install cracklib
fi
if [ ! -f /usr/bin/pwgen ]; then
yum -y -q install pwgen
fi
read -ep "Create FTP username for vhost domain (enter username): " ftpuser
read -ep "Do you want to auto generate FTP password (recommended) [y/n]: " autogenpass
if [[ "$autogenpass" = [yY] ]]; then
ftppass=$(pwgen -1cnys 27)
else
read -ep "Create FTP password for $ftpuser (enter password): " ftppass
# simple password strength check
# utilise http://cracklib.sourceforge.net/ too
CHECKPASSWD="$(cracklib-check <<<"$ftppass")"
okay="$(awk -F': ' '{ print $2}' <<<"$CHECKPASSWD")"
while [[ "$okay" != "OK" ]]; do
echo "!! password strength not strong enough !! "
echo "!! do not use common dictionary words !! "
echo "!! do not use short passwords !! "
echo "!! do not use simplistic passwords !! "
echo
read -ep "re-enter FTP password for $ftpuser (enter password): " ftppass
CHECKPASSWD="$(cracklib-check <<<"$ftppass")"
okay="$(awk -F': ' '{ print $2}' <<<"$CHECKPASSWD")"
done
fi # autogenpass
echo
echo "FTP username you entered: $ftpuser"
if [[ "$autogenpass" = [yY] ]]; then
echo "FTP password auto generated: $ftppass"
else
echo "FTP password you entered: $ftppass"
fi
fi
echo ""
if [ ! -d /home/nginx/domains/$vhostname ]; then
dbsetup
# Checking Permissions, making directories, example index.html
umask 027
mkdir -p /home/nginx/domains/$vhostname/{public,private,log,backup}
ngx_logformats
if [[ "$wpsubdirinstall" = [yY] ]]; then
mkdir -p /home/nginx/domains/$vhostname/public/$wpsubdir_value
fi
if [ ! -f /usr/local/nginx/conf/wpincludes ]; then
mkdir -p /usr/local/nginx/conf/wpincludes
fi
if [ ! -f "/usr/local/nginx/conf/wpincludes/$vhostname" ]; then
mkdir -p "/usr/local/nginx/conf/wpincludes/$vhostname"
fi
if [[ "$PUREFTPD_DISABLED" = [nN] ]]; then
( echo "${ftppass}" ; echo "${ftppass}" ) | pure-pw useradd "$ftpuser" -u $PUREUSER -g $PUREGROUP -d "/home/nginx/domains/$vhostname"
pure-pw mkdb
fi
if [[ "$wpsubdirinstall" = [yY] ]]; then
cat > "/home/nginx/domains/$vhostname/public/index.html" <<END
<html>
<head>
<title>$vhostname</title>
</head>
<body>
<p>Welcome to $vhostname. This index.html page can be removed. You have auto installed Wordpress at $vhostname$WPSUBDIR</p>
<p>Useful Centmin Mod info and links to bookmark.</p>
<ul>
<li>Getting Started Guide - <a href="https://centminmod.com/getstarted.html" target="_blank">https://centminmod.com/getstarted.html</a></li>
<li>Latest Centmin Mod version - <a href="https://centminmod.com" target="_blank">https://centminmod.com</a></li>
<li>Centmin Mod FAQ - <a href="https://centminmod.com/faq.html" target="_blank">https://centminmod.com/faq.html</a></li>
<li>Change Log - <a href="https://centminmod.com/changelog.html" target="_blank">https://centminmod.com/changelog.html</a></li>
<li>Google+ Page latest news <a href="https://centminmod.com/gpage" target="_blank">https://centminmod.com/gpage</a></li>
<li>Centmin Mod Community Forum <a href="https://community.centminmod.com/" target="_blank">https://community.centminmod.com/</a></li>
<li>Centmin Mod Twitter <a href="https://twitter.com/centminmod" target="_blank">https://twitter.com/centminmod</a></li>
<li>Centmin Mod Facebook Page <a href="https://www.facebook.com/centminmodcom" target="_blank">https://www.facebook.com/centminmodcom</a></li>
</ul>
<p><a href="https://www.digitalocean.com/?refcode=c1cb367108e8" target="_blank">Cheap VPS Hosting at Digitalocean</a></p>
</body>
</html>
END
fi
cp -R $CUR_DIR/htdocs/custom_errorpages/* /home/nginx/domains/$vhostname/public
umask 022
chown -R nginx:nginx "/home/nginx/domains/$vhostname"
find "/home/nginx/domains/$vhostname" -type d -exec chmod g+s {} \;
if [[ "$disablepwdprotect" != [yY] ]]; then
# wp-login.php password protection
if [[ -f /usr/local/nginx/conf/htpasswd.sh && ! -f /home/nginx/domains/$vhostname/htpasswd_wplogin ]]; then
HTWPLOGINSALT=$(/usr/bin/openssl rand -base64 16 | tr -dc 'a-zA-Z0-9')
HTWPLOGINSALTB=$(/usr/bin/openssl rand -base64 23 | tr -dc 'a-zA-Z0-9')
HTWPLOGIN=$RANDOM
HTWPLOGINB=$RANDOM
HTUSER="u${HTWPLOGINSALT}x${HTWPLOGIN}"
HTUSER=$(echo $HTUSER | sed -e 's|\/||g')
HTPASS="p${HTWPLOGINSALTB}y${HTWPLOGIN}"
HTPASS=$(echo $HTPASS | sed -e 's|\/||g')
echo "/usr/local/nginx/conf/htpasswd.sh create /home/nginx/domains/$vhostname/htpasswd_wplogin $HTUSER $HTPASS"
/usr/local/nginx/conf/htpasswd.sh create /home/nginx/domains/$vhostname/htpasswd_wplogin $HTUSER $HTPASS
fi
fi
# rate limit setup
WPRATECHECK=$(grep 'zone=xwplogin' /usr/local/nginx/conf/nginx.conf)
WPRATERPCCHECK=$(grep 'zone=xwprpc' /usr/local/nginx/conf/nginx.conf)
if [[ -z "$WPRATERPCCHECK" ]]; then
sed -i 's/http {/http { \nlimit_req_zone $binary_remote_addr zone=xwprpc:10m rate=30r\/s;\n/g' /usr/local/nginx/conf/nginx.conf
fi
if [[ -z "$WPRATECHECK" ]]; then
sed -i 's/http {/http { \nlimit_req_zone $binary_remote_addr zone=xwplogin:10m rate=40r\/m;\n/g' /usr/local/nginx/conf/nginx.conf
fi
################################################################################
# create wp super cache's included php config file php-wpsc.conf
\cp -f /usr/local/nginx/conf/php.conf /usr/local/nginx/conf/php-wpsc.conf
sed -i "s|fastcgi_param SERVER_NAME \$server_name;|fastcgi_param SERVER_NAME \$http_host;|" /usr/local/nginx/conf/php-wpsc.conf
################################################################################
# create wp enable enabler included files https://community.centminmod.com/posts/21220/
cat > "/usr/local/nginx/conf/wpincludes/${vhostname}/wpcacheenabler_${vhostname}.conf"<<HFA
# Block nginx-help log from public viewing
location ~* /wp-content/uploads/nginx-helper/ { deny all; }
set \$cache_uri \$request_uri;
# exclude mobile devices from redis caching
if (\$cmwpcache_device = mobile) { set \$cache_uri 'nullcache'; }
# bypass cache if POST requests or URLs with a query string
if (\$request_method = POST) {
set \$cache_uri 'nullcache';
}
if (\$query_string != "") {
set \$cache_uri 'nullcache';
}
# include query strings fbclid, gclid, utm in cache via stripping them with
# 302 redirect via mapping in /usr/local/nginx/conf/wpcacheenabler_map.conf
if (\$q_ignorearg) {
set \$check_qurl \$request_uri;
set \$check_surl \$request_uri;
set \$cache_uri \$uri;
#rewrite ^ \$uri? redirect;
}
add_header Check-Querystring-Uri "\$check_qurl";
#add_header Q-Ignore-Arg "\$q_ignorearg";
# bypass cache if URLs containing the following strings
if (\$request_uri ~* "(\?add-to-cart=|\?wc-ajax=|\?wc-api=|/cart/|/my-account/|/checkout/|/shop/checkout/|/wp-json/|/store/checkout/|/customer-dashboard/|/addons/|/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set \$cache_uri 'nullcache';
}
# bypass cache if the cookies containing the following strings
if (\$http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in|wc-api|edd_items_in_cart|woocommerce_items_in_cart|woocommerce_cart_hash|woocommerce_recently_viewed|wc_session_cookie_HASH|wp_woocommerce_session_|wptouch_switch_toggle") {
set \$cache_uri 'nullcache';
}
# bypass cache for woocommerce
if (\$arg_add-to-cart != "") { set \$cache_uri 'nullcache'; }
if (\$arg_wc-api != "") { set \$cache_uri 'nullcache'; }
## bypass cache for empty woocommerce carts
#if (\$cookie_woocommerce_items_in_cart != "0") {
# set \$cache_uri 'nullcache';
#}
# custom sub directory e.g. /blog
set \$custom_subdir '${WPSUBDIR}';
#if (\$args ~* s=(.*)) {
# set \$cache_uri \$request_uri;
# set \$check_surl \$cache_uri;
# set \$cache_uri /search/\$1;
#}
#add_header Check-Uri "\$check_surl";
#add_header Set-Uri "\$cache_uri";
# default html file
set \$cache_enabler_uri '\${custom_subdir}/wp-content/cache/cache-enabler/\${http_host}\${cache_uri}\${scheme}-index.html';
# webp html file
if (\$http_accept ~* "image/webp") {
set \$cache_enabler_uri_webp '\${custom_subdir}/wp-content/cache/cache-enabler/\${http_host}\${cache_uri}\${scheme}-index-webp.html';
}
#if (-f \$document_root\$cache_enabler_uri) {
#set \$cttls "120s";
#}
#expires \$cttls;
HFA
cat > "/usr/local/nginx/conf/wpcacheenabler_map.conf"<<HFB
map \$http_user_agent \$cmwpcache_device {
default 'desktop';
~*(iPad|iPhone|Android|IEMobile|Blackberry) 'mobile';
"~*Firefox.*Mobile" 'mobile';
"~*ipod.*mobile" 'mobile';
"~*Opera\ Mini" 'mobile';
"~*Opera\ Mobile" 'mobile';
"~*Mobile" 'mobile';
"~*Tablet" 'mobile';
"~*Kindle" 'mobile';
"~*Windows\ Phone" 'mobile';
}
map \$args \$q_ignorearg {
default 0;
"~*fbclid" 1;
"~*gclid" 1;
"~*utm" 1;
"~*fb_action_ids" 1;
"~*fb_action_types" 1;
"~*fb_source" 1;
"~*age-verified" 1;
"~*ao_noptimize" 1;
"~*usqp" 1;
"~*cn-reloaded" 1;
"~*_ga" 1;
"~*_ke" 1;
"~*mc_cid" 1;
"~*mc_eid" 1;
"~*ref" 1;
}
HFB
WPCACHEENABLERMAP_INCLUDECHECK=$(grep '\/usr\/local\/nginx\/conf\/wpcacheenabler_map.conf' /usr/local/nginx/conf/nginx.conf)
if [[ -z "$WPCACHEENABLERMAP_INCLUDECHECK" ]]; then
echo
echo "include file /usr/local/nginx/conf/wpcacheenabler_map.conf add to nginx.conf"
sed -i 's|\/usr\/local\/nginx\/conf\/fastcgi_param_https_map.conf;|\/usr\/local\/nginx\/conf\/fastcgi_param_https_map.conf;\ninclude \/usr\/local\/nginx\/conf\/wpcacheenabler_map.conf;|g' /usr/local/nginx/conf/nginx.conf
fi
################################################################################
# create nginx level redis cache included php config file php-rediscache.conf
# https://community.centminmod.com/posts/18828/
# \cp -f /usr/local/nginx/conf/php.conf /usr/local/nginx/conf/php-rediscache.conf
cat > "/usr/local/nginx/conf/php-rediscache.conf"<<HFF
location ~ [^/]\.php(/|\$) {
include /usr/local/nginx/conf/503include-only.conf;
fastcgi_split_path_info ^(.+?\.php)(/.*)\$;
if (!-f \$document_root\$fastcgi_script_name) {
return 404;
}
set \$key "nginx-cache:\$scheme\$request_method\$host\$request_uri";
srcache_fetch_skip \$skip_cache;
srcache_store_skip \$skip_cache;
srcache_response_cache_control off;
set_escape_uri \$escaped_key \$key;
srcache_fetch GET /redis-fetch \$key;
srcache_store PUT /redis-store key=\$escaped_key;
more_set_headers 'X-Cache \$srcache_fetch_status';
more_set_headers 'X-Cache-2 \$srcache_store_status';
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME \$request_filename;
#fastcgi_param PHP_ADMIN_VALUE open_basedir=\$document_root/:/usr/local/lib/php/:/tmp/;
# might shave 200+ ms off PHP requests
# which don't pass on a content length header
# slightly faster page response time at the
# expense of throughput / scalability
#sendfile on;
#tcp_nopush off;
#keepalive_requests 0;
fastcgi_connect_timeout 360s;
fastcgi_send_timeout 360s;
fastcgi_read_timeout 360s;
fastcgi_buffer_size 32k;
fastcgi_buffers 512 32k;
fastcgi_busy_buffers_size 1m;
fastcgi_temp_file_write_size 4m;
fastcgi_max_temp_file_size 4m;
fastcgi_intercept_errors off;
# next 3 lines when uncommented / enabled
# allow Nginx to handle uploads which then
# passes back the completed upload to PHP
#fastcgi_pass_request_body off;
#client_body_in_file_only clean;
#fastcgi_param REQUEST_BODY_FILE \$request_body_file;
#new .04+ map method
fastcgi_param HTTPS \$server_https;
# comment out PATH_TRANSLATED line if /usr/local/lib/php.ini sets following:
# cgi.fix_pathinfo=0
# as of centminmod v1.2.3-eva2000.01 default is set to cgi.fix_pathinfo=1
fastcgi_param PATH_INFO \$fastcgi_path_info;
fastcgi_param PATH_TRANSLATED \$document_root\$fastcgi_path_info;
fastcgi_param QUERY_STRING \$query_string;
fastcgi_param REQUEST_METHOD \$request_method;
fastcgi_param CONTENT_TYPE \$content_type;
fastcgi_param CONTENT_LENGTH \$content_length;
fastcgi_param SCRIPT_NAME \$fastcgi_script_name;
fastcgi_param REQUEST_URI \$request_uri;
fastcgi_param DOCUMENT_URI \$document_uri;
fastcgi_param DOCUMENT_ROOT \$document_root;
fastcgi_param SERVER_PROTOCOL \$server_protocol;
fastcgi_param REQUEST_SCHEME \$scheme;
fastcgi_param HTTPS \$https if_not_empty;
fastcgi_param HTTP_PROXY "";
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/\$nginx_version;
fastcgi_param REMOTE_ADDR \$remote_addr;
fastcgi_param REMOTE_PORT \$remote_port;
fastcgi_param SERVER_ADDR \$server_addr;
fastcgi_param SERVER_PORT \$server_port;
fastcgi_param SERVER_NAME \$server_name;
# Set php-fpm geoip variables
fastcgi_param GEOIP_COUNTRY_CODE \$geoip_country_code;
fastcgi_param GEOIP_COUNTRY_CODE3 \$geoip_country_code3;
fastcgi_param GEOIP_COUNTRY_NAME \$geoip_country_name;
fastcgi_param GEOIP_CITY_COUNTRY_CODE \$geoip_city_country_code;
fastcgi_param GEOIP_CITY_COUNTRY_CODE3 \$geoip_city_country_code3;
fastcgi_param GEOIP_CITY_COUNTRY_NAME \$geoip_city_country_name;
fastcgi_param GEOIP_REGION \$geoip_region;
fastcgi_param GEOIP_CITY \$geoip_city;
fastcgi_param GEOIP_POSTAL_CODE \$geoip_postal_code;
fastcgi_param GEOIP_CITY_CONTINENT_CODE \$geoip_city_continent_code;
fastcgi_param GEOIP_LATITUDE \$geoip_latitude;