/
nginx_configure.inc
4618 lines (4449 loc) · 244 KB
/
nginx_configure.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
mercurial_check() {
if [[ -f /usr/bin/hg && "$(hg version | head -n1 | grep -o '2.6')" = '2.6' ]]; then
if [[ "$CENTOS_SEVEN" -eq '7' ]]; then
yum -y localinstall https://centminmod.com/centminmodparts/mercurial/centos7/mercurial-4.9-1.x86_64.rpm
fi
elif [[ ! -f /usr/bin/hg ]]; then
if [[ "$CENTOS_SEVEN" -eq '7' ]]; then
yum -y localinstall https://centminmod.com/centminmodparts/mercurial/centos7/mercurial-4.9-1.x86_64.rpm
fi
fi
}
run_after_nginx_upgrade() {
if [[ -d /etc/centminmod && -f /etc/centminmod/run-after-nginx-upgrade.sh ]]; then
echo
echo "running /etc/centminmod/run-after-nginx-upgrade.sh"
bash /etc/centminmod/run-after-nginx-upgrade.sh
echo
fi
}
run_after_nginx_install() {
if [[ -d /etc/centminmod && -f /etc/centminmod/run-after-nginx-install.sh ]]; then
echo
echo "running /etc/centminmod/run-after-nginx-install.sh"
bash /etc/centminmod/run-after-nginx-install.sh
echo
fi
}
mold_check() {
if [[ "$CENTOS_SEVEN" = '7' && "$(uname -m)" = 'x86_64' ]] && [[ "$(rpm -qa centmin-mold | grep -o "centmin-mold-${MOLD_VERSION}")" != "centmin-mold-${MOLD_VERSION}" || ! -s /usr/local/libexec/mold ]]; then
echo "installing newer mold ${MOLD_VERSION}"
wget${ipv_forceopt_wget} -q "https://centminmod.com/centminmodparts/mold/centmin-mold-${MOLD_VERSION}-1.el7.x86_64.rpm" -O "${DIR_TMP}/centmin-mold-${MOLD_VERSION}-1.el7.x86_64.rpm"
echo "yum -y localinstall ${DIR_TMP}/centmin-mold-${MOLD_VERSION}-1.el7.x86_64.rpm"
yum -y localinstall "${DIR_TMP}/centmin-mold-${MOLD_VERSION}-1.el7.x86_64.rpm"
elif [[ "$CENTOS_EIGHT" = '8' && "$(uname -m)" = 'x86_64' ]] && [[ "$(rpm -qa centmin-mold | grep -o "centmin-mold-${MOLD_VERSION}")" != "centmin-mold-${MOLD_VERSION}" || ! -s /usr/local/libexec/mold ]]; then
echo "installing newer mold ${MOLD_VERSION}"
wget${ipv_forceopt_wget} -q "https://centminmod.com/centminmodparts/mold/centmin-mold-${MOLD_VERSION}-1.el8.x86_64.rpm" -O "${DIR_TMP}/centmin-mold-${MOLD_VERSION}-1.el8.x86_64.rpm"
echo "yum -y localinstall ${DIR_TMP}/centmin-mold-${MOLD_VERSION}-1.el8.x86_64.rpm"
yum -y localinstall "${DIR_TMP}/centmin-mold-${MOLD_VERSION}-1.el8.x86_64.rpm"
fi
}
detect_tlsonethree() {
if [ "$ngver" ]; then
NGINX_DIRINSTALL="$DIR_TMP/nginx-${ngver}"
else
NGINX_DIRINSTALL="$DIR_TMP/nginx-${NGINX_VERSION}"
fi
if [ -f /usr/local/nginx/conf/ssl-include.conf ]; then
if [[ "$OPENSSL_TLSONETHREE" = [yY] && "$(grep -w 'define NGX_SSL_TLSv1_3' "${NGINX_DIRINSTALL}/src/event/ngx_event_openssl.h")" ]]; then
# Nginx supports TLS 1.3 ssl_protocols directive
if [[ "$SSL_PROTOCOL_MODERN" = [yY] ]]; then
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1.2 TLSv1.3;|' /usr/local/nginx/conf/ssl-include.conf
elif [[ "$DISABLE_TLSONEZERO_PROTOCOL" = [yY] ]]; then
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;|' /usr/local/nginx/conf/ssl-include.conf
else
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;|' /usr/local/nginx/conf/ssl-include.conf
fi
else
if [[ "$SSL_PROTOCOL_MODERN" = [yY] ]]; then
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1.2;|' /usr/local/nginx/conf/ssl-include.conf
elif [[ "$DISABLE_TLSONEZERO_PROTOCOL" = [yY] ]]; then
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1.1 TLSv1.2;|' /usr/local/nginx/conf/ssl-include.conf
else
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1 TLSv1.1 TLSv1.2;|' /usr/local/nginx/conf/ssl-include.conf
fi
fi
elif [ -f /usr/local/nginx/conf/ssl_include.conf ]; then
if [[ "$OPENSSL_TLSONETHREE" = [yY] && "$(grep -w 'define NGX_SSL_TLSv1_3' "${NGINX_DIRINSTALL}/src/event/ngx_event_openssl.h")" ]]; then
# Nginx supports TLS 1.3 ssl_protocols directive
if [[ "$SSL_PROTOCOL_MODERN" = [yY] ]]; then
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1.2 TLSv1.3;|' /usr/local/nginx/conf/ssl_include.conf
elif [[ "$DISABLE_TLSONEZERO_PROTOCOL" = [yY] ]]; then
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;|' /usr/local/nginx/conf/ssl_include.conf
else
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;|' /usr/local/nginx/conf/ssl_include.conf
fi
else
if [[ "$SSL_PROTOCOL_MODERN" = [yY] ]]; then
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1.2;|' /usr/local/nginx/conf/ssl_include.conf
elif [[ "$DISABLE_TLSONEZERO_PROTOCOL" = [yY] ]]; then
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1.1 TLSv1.2;|' /usr/local/nginx/conf/ssl_include.conf
else
sed -i 's|ssl_protocols .*|ssl_protocols TLSv1 TLSv1.1 TLSv1.2;|' /usr/local/nginx/conf/ssl_include.conf
fi
fi
fi
}
dynamicmodule_file() {
if [ "$ngver" ]; then
NGINX_DIRINSTALL="$DIR_TMP/nginx-${ngver}"
else
NGINX_DIRINSTALL="$DIR_TMP/nginx-${NGINX_VERSION}"
fi
NGX_DYNAMICCHECK=$(grep 'DYNAMIC_MODULES=' "$NGINX_DIRINSTALL/auto/options")
if [ "$NGX_DYNAMICCHECK" ]; then
echo
echo "nginx dynamic module support detected"
echo
DYNAMIC_SUPPORT=y
# force disable nginx modsecurity module as it conflicts with nginx
# 1.9.11+ dynamic module builds
# NGINX_MODSECURITY='n'
# create include file to load nginx dynamic modules in main context in nginx.conf
if [[ "$INITIALINSTALL" != [yY] ]]; then
rm -rf /usr/local/nginx/conf/dynamic-modules.conf
fi
touch /usr/local/nginx/conf/dynamic-modules.conf
if [ ! -f /usr/local/nginx/conf/dynamic-modules-includes.conf ]; then
touch /usr/local/nginx/conf/dynamic-modules-includes.conf
fi
if [[ ! "$(grep -w 'dynamic-modules-includes.conf' /usr/local/nginx/conf/dynamic-modules.conf)" ]]; then
echo "# place custom load_module lines in this dynamic-modules-includes.conf" >> /usr/local/nginx/conf/dynamic-modules.conf
echo "# file so that they persistent i.e. for manually dropped in dynamic modules" >> /usr/local/nginx/conf/dynamic-modules.conf
echo "include /usr/local/nginx/conf/dynamic-modules-includes.conf;" >> /usr/local/nginx/conf/dynamic-modules.conf
fi
# setup include file /usr/local/nginx/conf/dynamic-modules.conf in nginx.conf
if [[ ! "$(grep 'dynamic-modules.conf' /usr/local/nginx/conf/nginx.conf)" ]]; then
sed -i 's|^pcre_jit on;|pcre_jit on;\ninclude \/usr\/local\/nginx\/conf\/dynamic-modules.conf;\n|g' /usr/local/nginx/conf/nginx.conf
sed -i 's|^pcre_jit off;|pcre_jit on;\ninclude \/usr\/local\/nginx\/conf\/dynamic-modules.conf;\n|g' /usr/local/nginx/conf/nginx.conf
fi
if [[ "$(grep 'dynamic-modules.conf' /usr/local/nginx/conf/nginx.conf)" ]]; then
sed -i 's|^#include \/usr\/local\/nginx\/conf\/dynamic-modules.conf;|include \/usr\/local\/nginx\/conf\/dynamic-modules.conf;|g' /usr/local/nginx/conf/nginx.conf
fi
# custom dynamic loading module flag include sourced file
if [ -f "${CONFIGSCANBASE}/custom_nginxmodules.inc" ]; then
# default is at /etc/centminmod/custom_nginxmodules.inc
source "${CONFIGSCANBASE}/custom_nginxmodules.inc"
fi
else
# comment out include file /usr/local/nginx/conf/dynamic-modules.conf in nginx.conf
# in it exists and you're moving to an nginx version that doesn't support dynamic module
# loading
if [ -f /usr/local/nginx/conf/dynamic-modules.conf ]; then
if [[ "$(grep 'dynamic-modules.conf' /usr/local/nginx/conf/nginx.conf)" ]]; then
sed -i 's|^include \/usr\/local\/nginx\/conf\/dynamic-modules.conf;|#include \/usr\/local\/nginx\/conf\/dynamic-modules.conf;|g' /usr/local/nginx/conf/nginx.conf
fi
fi
fi # NGX_DYNAMICCHECK check
}
ngx_dynamicfunction() {
if [ ! -d /usr/local/nginx/conf ]; then
mkdir -p /usr/local/nginx/conf
fi
if [ -d /usr/local/nginx/conf ]; then
# detection routine to see if Nginx supports Dynamic modules from nginx 1.9.11+
if [ -f "$(which figlet)" ]; then
figlet -ckf standard "Check Nginx Dynamic Module Support"
fi
echo
echo "NGX_DYNAMICCHECK nginx_configure"
pwd
dynamicmodule_file
if [ "$ngver" ]; then
DETECT_NGXVER=$(awk '/define nginx_version / {print $3}' "/svr-setup/nginx-$ngver/src/core/nginx.h")
echo "$DETECT_NGXVER"
else
DETECT_NGXVER=$(awk '/define nginx_version / {print $3}' "/svr-setup/nginx-${NGINX_VERSION}/src/core/nginx.h")
echo "$DETECT_NGXVER"
fi
if [[ "$DETECT_NGXVER" -ge '1011005' && "$DYNAMIC_SUPPORT" = [yY] ]]; then
WITHCOMPAT_OPT=' --with-compat'
else
WITHCOMPAT_OPT=""
fi
fi # check for /usr/local/nginx/conf
}
luaworkaroundfix() {
#################################################################################
# work around for lua-nginx-module 0.10 branch which adds new futures supported by
# openssl but not by libressl which nginx compiles against so this routine checks
# if lua-nginx-module 0.10 branch is loaded and switches back to openssl if detected
# https://community.centminmod.com/posts/24549/
CHECK_LUAVERSIONEND=$(echo "$ORESTY_LUANGINXVER" | cut -d . -f3)
CHECK_LUAVERSIONMID=$(echo "$ORESTY_LUANGINXVER" | cut -d . -f2)
CHECK_LUAVERSIONSTART=$(echo "$ORESTY_LUANGINXVER" | cut -d . -f1)
if [[ "$CHECK_LUAVERSIONEND" != '0' && "$CHECK_LUAVERSIONMID" -ge '10' && "$CHECK_LUAVERSIONSTART" -ge '0' ]]; then
LIBRESSL_SWITCH='n'
elif [[ "$CHECK_LUAVERSIONEND" -eq '0' && "$CHECK_LUAVERSIONMID" -ge '10' && "$CHECK_LUAVERSIONSTART" -ge '0' ]]; then
LIBRESSL_SWITCH='n'
luaopensslpatch
fi
}
libresslcompile_fix() {
if [[ "$(grep install_sw auto/lib/openssl/make >/dev/null 2>&1; echo $?)" -eq '0' ]]; then
if [[ "$LIBRESSL_SWITCH" = [yY] ]]; then
if [ -f auto/lib/openssl/make ]; then
sed -i 's|install_sw LIBDIR=lib|install LIBDIR=lib|' auto/lib/openssl/make
fi
fi
fi
}
funct_nginxconfigure() {
if [ -f "${CM_INSTALLDIR}/inc/custom_config.inc" ]; then
source "${CM_INSTALLDIR}/inc/custom_config.inc"
fi
if [ -f "${CONFIGSCANBASE}/custom_config.inc" ]; then
# default is at /etc/centminmod/custom_config.inc
dos2unix -q "${CONFIGSCANBASE}/custom_config.inc"
source "${CONFIGSCANBASE}/custom_config.inc"
fi
if [ -f "${CM_INSTALLDIR}/inc/z_custom.inc" ]; then
dos2unix -q "${CM_INSTALLDIR}/inc/z_custom.inc"
source "${CM_INSTALLDIR}/inc/z_custom.inc"
fi
# ensure HTTP/3 UDP port 443 is open
if [[ "$ngver" = 'quic' || "$NGINX_QUIC_SUPPORT" = [yY] ]]; then
if [[ ! "$(grep 'UDP_IN =' /etc/csf/csf.conf | grep -o '443')" ]]; then
csf --profile backup http3_udp_in
# csf --profile list
sed -i "s/UDP_IN = \"/UDP_IN = \"443,/g" /etc/csf/csf.conf
grep 'UDP_IN =' /etc/csf/csf.conf | grep -o '443'
csf -ra >/dev/null 2>&1
fi
if [[ ! "$(grep 'UDP_OUT =' /etc/csf/csf.conf | grep -o '443')" ]]; then
csf --profile backup http3_udp_out
# csf --profile list
sed -i "s/UDP_OUT = \"/UDP_OUT = \"443,/g" /etc/csf/csf.conf
grep 'UDP_OUT =' /etc/csf/csf.conf | grep -o '443'
csf -ra >/dev/null 2>&1
fi
if [[ ! "$(grep 'UDP6_IN =' /etc/csf/csf.conf | grep -o '443')" ]]; then
csf --profile backup http3_udp6_in
# csf --profile list
sed -i "s/UDP6_IN = \"/UDP6_IN = \"443,/g" /etc/csf/csf.conf
grep 'UDP6_IN =' /etc/csf/csf.conf | grep -o '443'
csf -ra >/dev/null 2>&1
fi
if [[ ! "$(grep 'UDP6_OUT =' /etc/csf/csf.conf | grep -o '443')" ]]; then
csf --profile backup http3_udp6_out
# csf --profile list
sed -i "s/UDP6_OUT = \"/UDP6_OUT = \"443,/g" /etc/csf/csf.conf
grep 'UDP6_OUT =' /etc/csf/csf.conf | grep -o '443'
csf -ra >/dev/null 2>&1
fi
fi
if [ -f "${CONFIGSCANBASE}/custom_config.inc" ]; then
OPENSSL_VERSION_CUSTOMCONFIG=$(awk -F "'" '/^OPENSSL_VERSION=/ {print $2}' "${CONFIGSCANBASE}/custom_config.inc")
if [[ "${OPENSSL_VERSION}" = '1.1.0j' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0j' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0i' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0h' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0g' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0f' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0e' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0d' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0c' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0b' || "$OPENSSL_VERSION_CUSTOMCONFIG" = '1.1.0a' ]]; then
# force old OpenSSL 1.1.0 branch versions to newer
# 1.1.1 branch if detected as some folks hardcode override
# OPENSSL_VERSION variable in /etc/centminmod/custom_config.inc
# and forget to update them and over time they are out of sync
# with OPENSSL_VERSION updated and set in centmin.sh
#
# also OpenSSL 1.1.0j seems to be failing Nginx compiles so this
# is a workaround to jump to 1.1.1a working version for now
OPENSSL_VERSION="$OPENSSL_VERSION_OLDOVERRIDE"
OPENSSL_LINKFILE="openssl-${OPENSSL_VERSION}.tar.gz"
OPENSSL_LINK="https://www.openssl.org/source/${OPENSSL_LINKFILE}"
fi
fi
ECNISTP_CHECK=$(gcc -dM -E - </dev/null | grep __SIZEOF_INT128__)
ECNISTP_ENDIAN=$(echo -n I | od -to2 | awk 'FNR==1{ print substr($2,6,1)}')
if [[ "$ECNISTP_ENDIAN" -ne '1' ]]; then
unset ECNISTP_CHECK
fi
if [[ "$NGINX_COMPILE_EXPORT" = [yY] ]]; then
NGINX_EXPORTLD_OPT='-Wl,-E '
fi
if [[ "$FORCE_IPVFOUR" != [yY] ]]; then
ipv_forceopt=""
ipv_forceopt_wget=""
WGETOPT="-cnv --no-dns-cache${ipv_forceopt_wget}"
else
ipv_forceopt='4'
ipv_forceopt_wget=' -4'
WGETOPT="-cnv --no-dns-cache${ipv_forceopt_wget}"
fi
if [[ "$NGX_LDMOLD" = [yY] ]]; then
mold_check
fi
if [[ "$NGINX_MODSECURITY" = [yY] ]]; then
# Nginx PCRE2 incompatible with current ModSecurity
# https://github.com/SpiderLabs/ModSecurity-nginx/issues/261
NGINX_PCRE_TWO='n'
fi
if [[ "$ORESTY_LUANGINX" = [yY] ]]; then
# Nginx PCRE2 incompatible with current Openresrt Nginx Lua module
# https://github.com/openresty/lua-nginx-module/issues/1984
NGINX_PCRE_TWO='n'
fi
if [[ "$NGINX_KTLS" = [yY] && "$KERNEL_NUMERICVER" -ge '5002000000' && "$DETECTOPENSSL_THREEZERO" = '3.0' ]]; then
KTLS_BUILD_TAG='-ktls'
NGINX_KTLS_OPT=' enable-ktls'
NGINX_KTLS_OPT_ALT='enable-ktls'
echo
echo "NGINX_KTLS_OPT=$NGINX_KTLS_OPT"
else
KTLS_BUILD_TAG=""
NGINX_KTLS_OPT=""
NGINX_KTLS_OPT_ALT=""
echo
echo "NGINX_KTLS_OPT=$NGINX_KTLS_OPT"
fi
# openssl 1.1.1 quictls fork for nginx-quic HTTP/3 builds
if [[ "$ngver" = 'quic' || "$NGINX_QUIC_SUPPORT" = [yY] ]] && [[ "$LIBRESSL_SWITCH" = [nN] && "$BORINGSSL_SWITCH" = [nN] ]]; then
if [[ "$NGINX_QUIC_RPMS" = [yY] && ! -f /opt/el-compat-quic/bin/openssl && "$CENTOS_SEVEN" -eq '7' ]]; then
yum -y localinstall "$DIR_TMP/centmin-openssl11-quic-compat-1.1.1q-1.el7.x86_64.rpm"
elif [[ "$NGINX_QUIC_RPMS" = [yY] && ! -f /opt/el-compat-quic/bin/openssl && "$CENTOS_EIGHT" -eq '8' ]]; then
yum -y localinstall "$DIR_TMP/centmin-openssl11-quic-compat-1.1.1q-1.el8.x86_64.rpm"
elif [[ "$NGINX_QUIC_RPMS" = [yY] && ! -f /opt/el-compat-quic/bin/openssl && "$CENTOS_NINE" -eq '9' ]]; then
yum -y localinstall "$DIR_TMP/centmin-openssl11-quic-compat-1.1.1q-1.el9.x86_64.rpm"
fi
QUICTLS_LD=' -lssl -lcrypto '
# QUICTLS_LD_OPT="-L../openssl-quic-nginx/lib ${QUICTLS_LD}"
# QUICTLS_CC_OPT='-I../openssl-quic-nginx/include '
# QUICTLS_RPATH='../openssl-quic-nginx/lib:'
QUICTLS_LD_OPT="-L/opt/openssl-quic/lib${QUICTLS_LD}"
QUICTLS_CC_OPT='-I/opt/openssl-quic/include '
QUICTLS_RPATH='/opt/openssl-quic/lib:'
NGINX_HPACK='n'
NGINX_DYNAMICTLS='n'
# if [ ! -f /opt/el-compat-quic/bin/openssl ]; then
# QUICTLS_LD_OPT=""
# QUICTLS_CC_OPT=""
# QUICTLS_RPATH=""
# QUICTLS_LD=""
# fi
else
QUICTLS_LD_OPT=""
QUICTLS_CC_OPT=""
QUICTLS_RPATH=""
QUICTLS_LD=""
fi
# adjustments for OpenSSL 1.1.0
DETECTOPENSSL_ONEZERO=$(echo $OPENSSL_VERSION | cut -d . -f1-2)
DETECTOPENSSL_ONEONE=$(echo $OPENSSL_VERSION | cut -d . -f1-3 | grep -o 1.1.1)
if [[ "$DETECTOPENSSL_ONEZERO" = '1.1' ]] || [[ "$DETECTOPENSSL_ONEONE" = '1.1.1' ]]; then
echo "detected $OPENSSL_VERSION"
WITHOPENSSL_OPT=""
WITHOPENSSL_OPTECHO=""
else
WITHOPENSSL_OPT=""
WITHOPENSSL_OPTECHO=""
fi
# override NGINX_OPENRESTY='n' if detected redis cache at nginx
# level as it requires NGINX_OPENRESTY='y' for dependent nginx
# modules provided by openresty
if [[ -d /usr/local/nginx/conf/wpincludes && "$(find /usr/local/nginx/conf/wpincludes -type f -name "rediscache.*" >/dev/null 2>&1; echo $?)" -eq '0' ]]; then
NGINX_OPENRESTY='y'
fi
# fix no longer needed with lua-nginx 0.10.2+
# https://github.com/openresty/lua-nginx-module/commit/b1a326eedf47b77e98b378fae1160e5340b75006
#luaworkaroundfix
#################################################################################
ngx_dynamicfunction
#################################################################################
# modsecurity_install
#################################################################################
# CUR_NGINXVER=$(nginx -v 2>&1 | awk -F '\\/' '{print $2}' |sed -e 's|\.|0|g' | head -n1)
# CUR_NGINXUPGRADEVER=$(echo $ngver |sed -e 's|\.|0|g' | head -n1)
# SET_NGINXVER=$(echo ${NGINX_VERSION} |sed -e 's|\.|0|g' | head -n1)
# assign NGX_VEREVAL nginx version based on if it's an initial
# centmin mod fresh install or a nginx upgrade run
if [[ "$INITIALINSTALL" != [yY] ]]; then
NGX_VEREVAL=${CUR_NGINXUPGRADEVER}
else
NGX_VEREVAL=${SET_NGINXVER}
fi
if [[ "$GPERFTOOLS_SOURCEINSTALL" = [yY] ]]; then
# lsof -n | grep tcmalloc >/dev/null 2>&1; echo $?
GPERFOPT=" --with-google_perftools_module"
mkdir -p /var/tmp/tcmalloc
chown -R nginx:nginx /var/tmp/tcmalloc
cat > "/usr/local/nginx/conf/gperftools.conf" <<GPF
google_perftools_profiles /var/tmp/tcmalloc;
GPF
GPERFINCLUDE_CHECK=$(grep '^include \/usr\/local\/nginx\/conf\/gperftools.conf;' /usr/local/nginx/conf/nginx.conf)
if [[ ! -z "$GPERFINCLUDE_CHECK" ]]; then
sed -i 's/^#include \/usr\/local\/nginx\/conf\/gperftools.conf;/include \/usr\/local\/nginx\/conf\/gperftools.conf;/g' /usr/local/nginx/conf/nginx.conf
elif [[ -z "$GPERFINCLUDE_CHECK" ]]; then
sed -i 's/pcre_jit on;/pcre_jit on; \ninclude \/usr\/local\/nginx\/conf\/gperftools.conf;/g' /usr/local/nginx/conf/nginx.conf
fi
else
GPERFOPT=""
sed -i 's|^include \/usr\/local\/nginx\/conf\/gperftools.conf|#include \/usr\/local\/nginx\/conf\/gperftools.conf|g' /usr/local/nginx/conf/nginx.conf
fi
if [[ "$NGINX_ZLIBNG" = [yY] && "$(uname -m)" = 'x86_64' ]]; then
zlibng_install
ZLIBNG_OPT=' --with-zlib=../zlib-ng'
CLOUDFLARE_ZLIB='n'
NGINX_ZLIBCUSTOM='n'
else
ZLIBNG_OPT=""
fi
if [[ "$CENTOS_SEVEN" = '7' || "$CENTOS_EIGHT" -eq '8' || "$CENTOS_NINE" -eq '9' || "$CENTOS_SIX" = '6' ]]; then
if [[ "$ngver" && "$ngver" = 'master-google' ]]; then
DETECT_NGXVER=$(awk '/define nginx_version / {print $3}' "/svr-setup/nginx-$ngver/src/core/nginx.h")
NGX_HPACK_OPT=""
NGINX_HPACK='n'
elif [[ "$ngver" && "$ngver" = 'quic' || "$NGINX_QUIC_SUPPORT" = [yY] ]]; then
DETECT_NGXVER=$(awk '/define nginx_version / {print $3}' "/svr-setup/nginx-$ngver/src/core/nginx.h")
NGX_HPACK_OPT=""
NGINX_HPACK='n'
elif [ "$ngver" ]; then
DETECT_NGXVER=$(awk '/define nginx_version / {print $3}' "/svr-setup/nginx-$ngver/src/core/nginx.h")
echo "$DETECT_NGXVER"
else
DETECT_NGXVER=$(awk '/define nginx_version / {print $3}' "/svr-setup/nginx-${NGINX_VERSION}/src/core/nginx.h")
echo "$DETECT_NGXVER"
fi
if [[ "$DETECT_NGXVER" -ge '1021005' && "$NGINX_PCRE_TWO" = [yY] && "$NGINX_PCRE_DYNAMIC" = [yY] && -s "$(readlink -f /usr/local/nginx-dep/lib/libpcre2-8.so)" ]]; then
pcre_two_dir_check
source_pcre_two_install
PCRE_TWO_RPATH='/usr/local/nginx-dep/lib:'
PCRE_TWO_LD=' -lpcre2-8'
elif [[ "$DETECT_NGXVER" -ge '1021005' && "$NGINX_PCRE_TWO" = [yY] && "$NGINX_PCRE_DYNAMIC" = [yY] && ! -s "$(readlink -f /usr/local/nginx-dep/lib/libpcre2-8.so)" ]]; then
pcre_two_dir_check
source_pcre_two_install
PCRE_TWO_RPATH='/usr/local/nginx-dep/lib:'
PCRE_TWO_LD=' -lpcre2-8'
fi
if [[ "$DETECT_NGXVER" -ge '1021005' && "$NGINX_PCRE_TWO" = [yY] ]]; then
PCRETWO_DISABLEOPT=''
echo
echo "--------------------------------"
echo "Nginx PCRE2 config check #1:"
echo "--------------------------------"
echo "DETECT_NGXVER=$DETECT_NGXVER"
echo "NGINX_PCRE_DYNAMIC=$NGINX_PCRE_DYNAMIC"
echo "NGINX_PCRE_TWO=$NGINX_PCRE_TWO"
echo "PCRETWO_DISABLEOPT=$PCRETWO_DISABLEOPT"
echo "NGINX_MIMALLOC=$NGINX_MIMALLOC"
echo "NGINX_MIMALLOC_VERSION=$NGINX_MIMALLOC_VERSION"
if [ -f /etc/centminmod/custom_config.inc ]; then
echo "Check /etc/centminmod/custom_config.inc relevant variables:"
egrep 'NGINX_PCRE|NGINX_MODSECURITY|ORESTY_LUANGINX' /etc/centminmod/custom_config.inc
fi
echo
echo "ls -lAhrt /usr/local/nginx-dep/lib | egrep 'libpcre.so|libpcre2-8.so'"
ls -lAhrt /usr/local/nginx-dep/lib | egrep 'libpcre.so|libpcre2-8.so'
echo
elif [[ "$DETECT_NGXVER" -ge '1021005' && "$NGINX_PCRE_TWO" != [yY] ]]; then
PCRETWO_DISABLEOPT=' --without-pcre2'
echo
echo "--------------------------------"
echo "Nginx PCRE config check #1:"
echo "--------------------------------"
echo "DETECT_NGXVER=$DETECT_NGXVER"
echo "NGINX_PCRE_DYNAMIC=$NGINX_PCRE_DYNAMIC"
echo "NGINX_PCRE_TWO=$NGINX_PCRE_TWO"
echo "PCRETWO_DISABLEOPT=$PCRETWO_DISABLEOPT"
echo "NGINX_MIMALLOC=$NGINX_MIMALLOC"
echo "NGINX_MIMALLOC_VERSION=$NGINX_MIMALLOC_VERSION"
if [ -f /etc/centminmod/custom_config.inc ]; then
echo "Check /etc/centminmod/custom_config.inc relevant variables:"
egrep 'NGINX_PCRE|NGINX_MODSECURITY|ORESTY_LUANGINX' /etc/centminmod/custom_config.inc
fi
echo
echo "ls -lAhrt /usr/local/nginx-dep/lib | egrep 'libpcre.so|libpcre2-8.so'"
ls -lAhrt /usr/local/nginx-dep/lib | egrep 'libpcre.so|libpcre2-8.so'
echo
fi
# if openssl 1.1.1 breaks HPACK patching
# if [[ "$TLSONETHREE_DETECT" = [yY] ]]; then
# NGINX_HPACK='n'
# NGX_HPACK_OPT=""
# fi
# DETECTOPENSSL_ONEZERO=$(echo $OPENSSL_VERSION | cut -d . -f1-2)
# if [[ "$DETECTOPENSSL_ONEZERO" = '1.0' ]]; then
# NGINX_HPACK='n'
# NGX_HPACK_OPT=""
# fi
if [[ "$NGINX_IOURING_PATCH_BETA" = [yY] && "$DETECT_NGXVER" -gt '1017000' && "$KERNEL_NUMERICVER" -ge '5001000000' ]]; then
NGX_IORING_OPT=' --with-file-aio'
fi
# if [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -ge '1013006' && "$DETECT_NGXVER" -lt '1013009' ]]; then
if [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -ge '1013006' && "$DETECT_NGXVER" -lt '1013010' ]]; then
NGX_HPACK_OPT=' --with-http_v2_hpack_enc'
elif [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -ge '1013010' && "$DETECT_NGXVER" -le '1013012' ]]; then
NGX_HPACK_OPT=' --with-http_v2_hpack_enc'
elif [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -eq '1014000' ]]; then
NGX_HPACK_OPT=' --with-http_v2_hpack_enc'
elif [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -ge '1015000' && "$DETECT_NGXVER" -le '1015007' ]]; then
NGX_HPACK_OPT=' --with-http_v2_hpack_enc'
elif [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -ge '1015008' && "$DETECT_NGXVER" -le '1017010' ]]; then
NGX_HPACK_OPT=' --with-http_v2_hpack_enc'
elif [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -ge '1017011' && "$DETECT_NGXVER" -le '1019010' ]]; then
NGX_HPACK_OPT=' --with-http_v2_hpack_enc'
elif [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -ge '1020000' && "$DETECT_NGXVER" -le '1020001' ]]; then
NGX_HPACK_OPT=' --with-http_v2_hpack_enc'
elif [[ "$NGINX_HPACK" = [yY] && "$DETECT_NGXVER" -ge '1021000' && "$DETECT_NGXVER" -le "$NGINX_HPACK_ALLOWED_VER" ]]; then
NGX_HPACK_OPT=' --with-http_v2_hpack_enc'
else
NGX_HPACK_OPT=""
fi
if [[ "$NGINX_PRIORITIZECHACHA" = [yY] && "$DETECT_NGXVER" -ge '1015004' && "$(echo $OPENSSL_VERSION | grep -o '1.1.1')" = '1.1.1' ]]; then
ngx_prioritizechacha_patch
fi
if [[ "$NGINX_HTTPPUSH" = [yY] ]]; then
NGINX_HTTP2='y'
ngx_httppush_patch
HTTP_PUSHOPT=' --add-module=../http2-push-nginx-module'
else
HTTP_PUSHOPT=""
fi
if [[ "$NGINX_TLS_FINGERPRINT" = [yY] && "$DETECTOPENSSL_ONEONE" && "$DETECTOPENSSL_ONEONE" = '1.1.1' ]] && [[ "$LIBRESSL_SWITCH" = [nN] ]] && [[ "$BORINGSSL_SWITCH" = [nN] ]]; then
# only proceed if OpenSSL is installed with Nginx and not LibreSSL or BoringSSL variants
ngx_fingerprint_patch
HTTP_FINGERPRINTOPT=' --add-module=../nginx-ssl-fingerprint'
else
HTTP_FINGERPRINTOPT=""
fi
if [[ "$NGINX_SLICE" = [yY] ]]; then
NGXSLICEOPT=' --with-http_slice_module'
else
NGXSLICEOPT=""
fi
if [[ "$NGINX_RTMP" = [yY] ]]; then
if [[ ! -d "${DIR_TMP}/nginx-rtmp-module" ]]; then
echo
echo "download nginx-rtmp-module from github"
pushd "$DIR_TMP"
time git clone https://github.com/arut/nginx-rtmp-module
echo
popd
elif [[ -d "${DIR_TMP}/nginx-rtmp-module" && -d "${DIR_TMP}/nginx-rtmp-module/.git" ]]; then
echo
echo "get latest updates nginx-rtmp-module from github"
pushd "${DIR_TMP}/nginx-rtmp-module"
git stash
git pull
git log -1
echo
popd
fi
fi
if [[ "$NGINX_DEBUG" = [yY] ]]; then
NGINX_DEBUGOPT=' --with-debug'
STRIPNGINX=n
else
NGINX_DEBUGOPT=""
fi
if [[ "$DETECT_NGXVER" -ge '1011005' && "$NGINX_STREAMSSLPREREAD" = [yY] ]]; then
STREAM_SSLPREREADOPT=" --with-stream_ssl_preread_module"
else
STREAM_SSLPREREADOPT=""
fi
if [[ "$NGINX_HTTP2" = [yY] ]]; then
# only apply Nginx HTTP/2 if Nginx version is >= 1.9.3 and <1.9.5 OR >= 1.9.5
if [[ "$DETECT_NGXVER" -ge '1009003' && "$DETECT_NGXVER" -lt '1009005' ]] || [[ "$DETECT_NGXVER" -ge '1009005' ]] || [[ "$NGX_VEREVAL" = 'master' ]] || [[ "$NGX_VEREVAL" = 'quic' ]] || [[ "$NGX_VEREVAL" = 'master-google' ]]; then
if [[ "$NGINX_SPDYPATCHED" = [yY] ]]; then
NGINX_SPDY=y
HTTPTWOOPT=' --with-http_spdy_module --with-http_v2_module'
else
NGINX_SPDY=n
if [[ "$ngver" = 'quic' || "$NGINX_QUIC_SUPPORT" = [yY] ]]; then
if [[ "$NGINX_QUIC_DEBUG" = [yY] ]]; then
HTTPTWOOPT=' --with-debug --with-http_v2_module --with-http_v3_module --with-stream_quic_module'
# HTTPTWOOPT=' --with-http_v3_module --with-stream_quic_module'
else
HTTPTWOOPT=' --with-http_v2_module --with-http_v3_module --with-stream_quic_module'
fi
else
HTTPTWOOPT=' --with-http_v2_module'
fi
fi
fi
else
HTTPTWOOPT=""
if [[ "$DETECT_NGXVER" -lt '1009003' ]]; then
NGINX_SPDY=y
fi
fi
if [[ "$NGINX_REALIP" = [yY] ]]; then
REALIPOPT=' --with-http_realip_module'
else
REALIPOPT=""
fi
if [[ "$NGINX_RDNS" = [yY] ]]; then
cd "$DIR_TMP"
rm -rf nginx-http-rdns
time git clone https://github.com/flant/nginx-http-rdns.git nginx-http-rdns
RDNSOPT=" --add-module=../nginx-http-rdns"
else
RDNSOPT=""
fi
if [[ "$NGINX_STUBSTATUS" = [yY] ]]; then
STUBSTATUSOPT=" --with-http_stub_status_module"
else
STUBSTATUSOPT=""
fi
if [[ "$NGINX_SUB" = [yY] ]]; then
SUBOPT=" --with-http_sub_module"
else
SUBOPT=""
fi
if [[ "$NGINX_ADDITION" = [yY] ]]; then
ADDITIONOPT=" --with-http_addition_module"
else
ADDITIONOPT=""
fi
if [[ "$NGINX_TESTCOOKIE" = [yY] ]]; then
NGINX_TESTCOOKIEGIT='y'
NGX_TESTCOOKIEDIR='testcookie-nginx-module'
if [[ "$NGINX_TESTCOOKIEGIT" = [yY] ]]; then
pushd "$DIR_TMP"
rm -rf testcookie-nginx-module
time git clone -b master --depth=1 https://github.com/kyprizel/testcookie-nginx-module
popd
fi
# nginx 1.9.11+ dynamic module support
# https://github.com/openresty/headers-more-nginx-module#installation
if [[ "$DYNAMIC_SUPPORT" = [yY] && "$NGXDYNAMIC_TESTCOOKIE" = [yY] ]]; then
if [[ "$NGINX_TESTCOOKIEGIT" = [yY] ]]; then
TESTCOOKIEOPT=" --add-dynamic-module=../testcookie-nginx-module"
else
TESTCOOKIEOPT=" --add-dynamic-module=../$NGX_TESTCOOKIEDIR"
fi
if [ -f /usr/local/nginx/conf/dynamic-modules.conf ]; then
echo "load_module \"modules/ngx_http_testcookie_access_module.so\";" >> /usr/local/nginx/conf/dynamic-modules.conf
fi
if [ -f /usr/local/nginx/modules/ngx_http_testcookie_access_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_testcookie_access_module.so.old
fi
else
if [[ "$NGINX_TESTCOOKIEGIT" = [yY] ]]; then
TESTCOOKIEOPT=" --add-module=../testcookie-nginx-module"
else
TESTCOOKIEOPT=" --add-module=../$NGX_TESTCOOKIEDIR"
fi
# if NGXDYNAMIC_TESTCOOKIE='y' was previously set with nginx 1.9.11+, then the nginx
# dynamic module /usr/local/nginx/modules/ngx_http_testcookie_access_module.so would of been
# created
# however, it seems if you then later recompile nginx with NGXDYNAMIC_TESTCOOKIE='y'
# the old dynamic module would still be left in nginx dynamic modules directory
# this is a check for that old dynamic module and if it exists, remove it
if [[ -f /usr/local/nginx/modules/ngx_http_testcookie_access_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_testcookie_access_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_testcookie_access_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_testcookie_access_module.so.old
fi
fi
else
TESTCOOKIEOPT=""
if [[ -f /usr/local/nginx/modules/ngx_http_testcookie_access_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_testcookie_access_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_testcookie_access_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_testcookie_access_module.so.old
fi
fi
if [[ "$NGINX_LENGTHHIDE" = [yY] ]]; then
NGINX_LENGTHHIDEGIT='y'
NGX_HIDELENGTHDIR='nginx-length-hiding-filter-module'
if [[ "$NGINX_LENGTHHIDEGIT" = [yY] ]]; then
pushd "$DIR_TMP"
rm -rf nginx-length-hiding-filter-module
time git clone -b master --depth=1 https://github.com/nulab/nginx-length-hiding-filter-module nginx-length-hiding-filter-module
popd
fi
# nginx 1.9.11+ dynamic module support
# https://github.com/openresty/headers-more-nginx-module#installation
if [[ "$DYNAMIC_SUPPORT" = [yY] && "$NGXDYNAMIC_HIDELENGTH" = [yY] ]]; then
if [[ "$NGINX_LENGTHHIDEGIT" = [yY] ]]; then
HIDELENGTHOPT=" --add-dynamic-module=../nginx-length-hiding-filter-module"
else
HIDELENGTHOPT=" --add-dynamic-module=../$NGX_HIDELENGTHDIR"
fi
if [ -f /usr/local/nginx/conf/dynamic-modules.conf ]; then
echo "load_module \"modules/ngx_http_length_hiding_filter_module.so\";" >> /usr/local/nginx/conf/dynamic-modules.conf
fi
if [ -f /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so.old
fi
else
if [[ "$NGINX_LENGTHHIDEGIT" = [yY] ]]; then
HIDELENGTHOPT=" --add-module=../nginx-length-hiding-filter-module"
else
HIDELENGTHOPT=" --add-module=../$NGX_HIDELENGTHDIR"
fi
# if NGXDYNAMIC_HIDELENGTH='y' was previously set with nginx 1.9.11+, then the nginx
# dynamic module /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so would of been
# created
# however, it seems if you then later recompile nginx with NGXDYNAMIC_HIDELENGTH='y'
# the old dynamic module would still be left in nginx dynamic modules directory
# this is a check for that old dynamic module and if it exists, remove it
if [[ -f /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so.old
fi
fi
else
HIDELENGTHOPT=""
if [[ -f /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_length_hiding_filter_module.so.old
fi
fi
if [[ "$NGINX_IMAGEFILTER" = [yY] ]]; then
if [[ "$DYNAMIC_SUPPORT" = [yY] && "$NGXDYNAMIC_IMAGEFILTER" = [yY] ]]; then
IMAGEFILTEROPT=" --with-http_image_filter_module=dynamic"
if [ -f /usr/local/nginx/conf/dynamic-modules.conf ]; then
echo "load_module \"modules/ngx_http_image_filter_module.so\";" >> /usr/local/nginx/conf/dynamic-modules.conf
fi
if [ -f /usr/local/nginx/modules/ngx_http_image_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_image_filter_module.so.old
fi
else
IMAGEFILTEROPT=" --with-http_image_filter_module"
# if NGXDYNAMIC_IMAGEFILTER='y' was previously set with nginx 1.9.11+, then the nginx
# dynamic module /usr/local/nginx/modules/ngx_http_lua_module.so would of been
# created
# however, it seems if you then later recompile nginx with NGXDYNAMIC_IMAGEFILTER='y'
# the old dynamic module would still be left in nginx dynamic modules directory
# this is a check for that old dynamic module and if it exists, remove it
if [[ -f /usr/local/nginx/modules/ngx_http_image_filter_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_image_filter_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_image_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_image_filter_module.so.old
fi
fi
else
IMAGEFILTEROPT=""
if [[ -f /usr/local/nginx/modules/ngx_http_image_filter_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_image_filter_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_image_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_image_filter_module.so.old
fi
fi
if [[ "$NGINX_XSLT" = [yY] ]]; then
if [[ "$DYNAMIC_SUPPORT" = [yY] && "$NGXDYNAMIC_XSLT" = [yY] ]]; then
NGXXSLTOPT=" --with-http_xslt_module=dynamic"
if [ -f /usr/local/nginx/conf/dynamic-modules.conf ]; then
echo "load_module \"modules/ngx_http_xslt_filter_module.so\";" >> /usr/local/nginx/conf/dynamic-modules.conf
fi
if [ -f /usr/local/nginx/modules/ngx_http_xslt_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_xslt_filter_module.so.old
fi
else
NGXXSLTOPT=" --with-http_xslt_module"
# if NGXDYNAMIC_XSLT='y' was previously set with nginx 1.9.11+, then the nginx
# dynamic module /usr/local/nginx/modules/ngx_http_lua_module.so would of been
# created
# however, it seems if you then later recompile nginx with NGXDYNAMIC_XSLT='y'
# the old dynamic module would still be left in nginx dynamic modules directory
# this is a check for that old dynamic module and if it exists, remove it
if [[ -f /usr/local/nginx/modules/ngx_http_xslt_filter_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_xslt_filter_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_xslt_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_xslt_filter_module.so.old
fi
fi
else
NGXXSLTOPT=""
if [[ -f /usr/local/nginx/modules/ngx_http_xslt_filter_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_xslt_filter_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_xslt_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_xslt_filter_module.so.old
fi
fi
if [[ "$NGINX_PERL" = [yY] ]]; then
if [ ! -f /usr/share/perl5/ExtUtils/Embed.pm ]; then
time $YUMDNFBIN -q -y install perl-ExtUtils-Embed
fi
if [[ "$DYNAMIC_SUPPORT" = [yY] && "$NGXDYNAMIC_PERL" = [yY] ]]; then
NGXPERLOPT=" --with-http_perl_module=dynamic"
if [ -f /usr/local/nginx/conf/dynamic-modules.conf ]; then
echo "load_module \"modules/ngx_http_perl_module.so\";" >> /usr/local/nginx/conf/dynamic-modules.conf
fi
if [ -f /usr/local/nginx/modules/ngx_http_perl_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_perl_module.so.old
fi
else
NGXPERLOPT=" --with-http_perl_module"
# if NGXDYNAMIC_PERL='y' was previously set with nginx 1.9.11+, then the nginx
# dynamic module /usr/local/nginx/modules/ngx_http_lua_module.so would of been
# created
# however, it seems if you then later recompile nginx with NGXDYNAMIC_PERL='y'
# the old dynamic module would still be left in nginx dynamic modules directory
# this is a check for that old dynamic module and if it exists, remove it
if [[ -f /usr/local/nginx/modules/ngx_http_perl_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_perl_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_perl_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_perl_module.so.old
fi
fi
else
NGXPERLOPT=""
if [[ -f /usr/local/nginx/modules/ngx_http_perl_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_perl_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_perl_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_perl_module.so.old
fi
fi
if [[ "$NGINX_CACHEPURGE" = [yY] ]]; then
# ngx_cachepurge_patch
NGX_CACHEPURGEDIR=$(tar -tzf "$DIR_TMP/${NGX_CACHEPURGEFILE}" | head -1 | cut -f1 -d"/")
CACHEPURGEOPT=" --add-module=../$NGX_CACHEPURGEDIR"
else
CACHEPURGEOPT=""
fi
if [[ "$NGINX_ACCESSKEY" = [yY] ]]; then
ACCESSKEYOPT=" --add-module=../nginx-accesskey-2.0.3"
else
ACCESSKEYOPT=""
fi
if [[ "$NGINX_HTTPCONCAT" = [yY] ]]; then
NGX_CONCATDIR=$(tar -tzf "$DIR_TMP/${NGX_CONCATLINKFILE}" | head -1 | cut -f1 -d"/")
HTTPCONCATOPT=" --add-module=../$NGX_CONCATDIR"
else
HTTPCONCATOPT=""
fi
if [[ "$ORESTY_HEADERSMORE" = [yY] ]]; then
NGX_HEADERSMOREDIR=$(tar -tzf "$DIR_TMP/${NGX_HEADERSMORELINKFILE}" | head -1 | cut -f1 -d"/")
# gitmaster option
if [[ "$ORESTY_HEADERSMOREGIT" = [yY] ]]; then
pushd "$DIR_TMP"
rm -rf headers-more-nginx-module-master
time git clone -b master --depth=1 https://github.com/openresty/headers-more-nginx-module.git headers-more-nginx-module-master
popd
fi
# nginx 1.9.11+ dynamic module support
# https://github.com/openresty/headers-more-nginx-module#installation
if [[ "$DYNAMIC_SUPPORT" = [yY] && "$NGXDYNAMIC_HEADERSMORE" = [yY] ]]; then
if [[ "$ORESTY_HEADERSMOREGIT" = [yY] ]]; then
HEADERSMOREOPT=" --add-dynamic-module=../headers-more-nginx-module-master"
else
HEADERSMOREOPT=" --add-dynamic-module=../$NGX_HEADERSMOREDIR"
fi
if [ -f /usr/local/nginx/conf/dynamic-modules.conf ]; then
echo "load_module \"modules/ngx_http_headers_more_filter_module.so\";" >> /usr/local/nginx/conf/dynamic-modules.conf
fi
if [ -f /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so.old
fi
else
if [[ "$ORESTY_HEADERSMOREGIT" = [yY] ]]; then
HEADERSMOREOPT=" --add-module=../headers-more-nginx-module-master"
else
HEADERSMOREOPT=" --add-module=../$NGX_HEADERSMOREDIR"
fi
# if NGXDYNAMIC_HEADERSMORE='y' was previously set with nginx 1.9.11+, then the nginx
# dynamic module /usr/local/nginx/modules/ngx_http_lua_module.so would of been
# created
# however, it seems if you then later recompile nginx with NGXDYNAMIC_HEADERSMORE='y'
# the old dynamic module would still be left in nginx dynamic modules directory
# this is a check for that old dynamic module and if it exists, remove it
if [[ -f /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so.old
fi
fi
else
HEADERSMOREOPT=""
if [[ -f /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so && "$NGXDYNAMIC_MANUALOVERRIDE" != [yY] ]]; then
rm -rf /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so
fi
if [ -f /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so.old ]; then
rm -rf /usr/local/nginx/modules/ngx_http_headers_more_filter_module.so.old
fi
fi
if [[ "$NGINX_HTTPREDIS" = [yY] ]]; then
NGX_HTTPREDISDIR=$(tar -tzf "$DIR_TMP/${NGX_HTTPREDISLINKFILE}" | head -1 | cut -f1 -d"/")
HTTPREDISOPT=" --add-module=../$NGX_HTTPREDISDIR"
else
HTTPREDISOPT=""
fi
if [[ "$NGINX_AUTHREQ" = [yY] ]]; then
AUTHREQOPT=' --with-http_auth_request_module'
else
AUTHREQOPT=""
fi
if [[ "$LIBRESSL_SWITCH" = [yY] ]]; then
LIBRESSLDIR=$(tar -tzf "$DIR_TMP/${LIBRESSL_LINKFILE}" 2>&1 | head -1 | cut -f1 -d"/" | grep libressl)
LIBRESSLOPT=" --with-openssl=../$LIBRESSLDIR"
OPENSSLOPT=""
BORINGSSLOPT=""
LRT='-lrt '
elif [[ "$BORINGSSL_SWITCH" = [yY] ]]; then
LIBRESSLOPT=""
OPENSSLOPT=""
# LRT=""
LRT='-lrt '
# BORINGSSLOPT=" --with-openssl=${BORINGSSL_DIR}/boringssl"
BORINGSSL_RPATH="${BORINGSSL_DIR}/boringssl/.openssl/lib:"
BORINGSSL_LIBOPT="-L${BORINGSSL_DIR}/boringssl/.openssl/lib -lcrypto -lssl "
BORINGSSLINC_OPT="-I${BORINGSSL_DIR}/boringssl/.openssl/include "
# openresty set-misc nginx module not compatible with boringssl
# https://community.centminmod.com/threads/15406/
#ORESTY_SETMISC='n'
#NGINX_STREAM='n'
#SETMISCOPT=""
else
if [ "$NOSOURCEOPENSSL" == 'n' ]; then
OPENSSLDIR=$(tar -tzf "$DIR_TMP/${OPENSSL_LINKFILE}" | head -1 | cut -f1 -d"/")
LIBRESSLOPT=""
BORINGSSLOPT=""
if [[ "$TLSONETHREE" = [yY] && "$ORESTY_LUANGINX" != [yY] ]] || [[ "$TLSONETHREE" = [yY] && "$ORESTY_LUANGINX" = [yY] ]]; then
echo 1a
if [[ "$(uname -m)" = 'x86_64' ]]; then
OPENSSLOPT=" --with-openssl=../openssl-tls1.3"
TLSTHREEOPT='y'
else
OPENSSLOPT=" --with-openssl=../openssl-tls1.3"
OPENSSLOPT_B=" --with-openssl-opt=enable-tls1_3"
fi
elif [[ "$DETECTOPENSSL_ONEONE" = '1.1.1' && "$ORESTY_LUANGINX" != [yY] ]] || [[ "$DETECTOPENSSL_ONEONE" = '1.1.1' && "$ORESTY_LUANGINX" = [yY] ]]; then
echo 1b
if [[ "$(uname -m)" = 'x86_64' ]]; then
if [[ "$ECNISTP_CHECK" && ! -d "${DIR_TMP}/${OPENSSL_QUIC_DIR}" ]]; then
OPENSSLOPT=" --with-openssl=../$OPENSSLDIR --with-openssl-opt='enable-ec_nistp_64_gcc_128'"
else
OPENSSLOPT=" --with-openssl=../$OPENSSLDIR"
fi
TLSTHREEOPT='y'
else
OPENSSLOPT=" --with-openssl=../$OPENSSLDIR"
OPENSSLOPT_B=" --with-openssl-opt=enable-tls1_3"
fi
elif [[ "$NGINX_KTLS" = [yY] && "$KERNEL_NUMERICVER" -ge '5002000000' && "$DETECTOPENSSL_THREEZERO" = '3.0' ]]; then
OPENSSLOPT=" --with-openssl=../$OPENSSLDIR --with-openssl-opt='${NGINX_KTLS_OPT_ALT}'"
else
echo 1c
if [[ "$(uname -m)" = 'x86_64' ]]; then
if [[ "$ECNISTP_CHECK" && ! -d "${DIR_TMP}/${OPENSSL_QUIC_DIR}" ]]; then
OPENSSLOPT=" --with-openssl=../$OPENSSLDIR --with-openssl-opt='enable-ec_nistp_64_gcc_128'"
else
OPENSSLOPT=" --with-openssl=../$OPENSSLDIR"
fi
else
OPENSSLOPT=" --with-openssl=../$OPENSSLDIR"
fi
fi
LRT=""
else
OPENSSLDIR=$(tar -tzf "$DIR_TMP/${OPENSSL_LINKFILE}" | head -1 | cut -f1 -d"/")
# export OPENSSL_BPATH=$DIR_TMP