Skip to content

Commit 1d9c521

Browse files
committed
backport from 123.09beta01 to 123.08stable inc/wpsetup.inc and vhost ssl changes
- backport to inc/wpsetup.inc support for self signed ssl vhost generation with wordpress auto installer - backport self signed ssl certificate variables to centmin.sh https://community.centminmod.com/posts/17872/ - backport to tools/nv.sh - backport and add standalone tools/nvwp.sh wordpress install for PHP 7 usage as WP-CLI doesn't support PHP 7 and thus centmin.sh menu option 22 doesn't work for PHP 7 based servers
1 parent 54d8b72 commit 1d9c521

File tree

5 files changed

+1703
-140
lines changed

5 files changed

+1703
-140
lines changed

centmin.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,28 @@ CUSTOM_CURLRPMCARESVER='1.10.0-5.0' # c-ares version
455455
CUSTOM_CURLRPMSYSURL='http://mirror.city-fan.org/ftp/contrib/sysutils/Mirroring'
456456
CUSTOM_CURLRPMLIBURL='http://mirror.city-fan.org/ftp/contrib/libraries'
457457
###############################################################
458+
# Settings for centmin.sh menu option 2 and option 22 for
459+
# the details of the self-signed SSL certificate that is auto
460+
# generated. The default values where vhostname variable is
461+
# auto added based on what you input for your site name
462+
#
463+
# -subj "/C=US/ST=California/L=Los Angeles/O=${vhostname}/OU=${vhostname}/CN=${vhostname}"
464+
#
465+
# You can only customise the first 5 variables for
466+
# C = Country 2 digit code
467+
# ST = state
468+
# L = Location as in city
469+
# 0 = organisation
470+
# OU = organisational unit
471+
#
472+
# if left blank # defaults to same as vhostname that is your domain
473+
# if set it overrides that
474+
SELFSIGNEDSSL_C='US'
475+
SELFSIGNEDSSL_ST='California'
476+
SELFSIGNEDSSL_L='Los Angeles'
477+
SELFSIGNEDSSL_O=''
478+
SELFSIGNEDSSL_OU=''
479+
###############################################################
458480

459481
MACHINE_TYPE=`uname -m` # Used to detect if OS is 64bit or not.
460482

inc/nginx_addvhost.inc

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,71 @@ cd /usr/local/nginx/conf/ssl/${vhostname}
2525

2626
cecho "---------------------------------------------------------------" $boldyellow
2727
cecho "Generating self signed SSL certificate..." $boldgreen
28-
sleep 5
28+
cecho "CSR file can also be used to be submitted for paid SSL certificates" $boldgreen
29+
cecho "If using for paid SSL certificates be sure to keep both private key and CSR safe" $boldgreen
30+
cecho "creating CSR File: ${vhostname}.csr" $boldgreen
31+
cecho "creating private key: ${vhostname}.key" $boldgreen
32+
cecho "creating self-signed SSL certificate: ${vhostname}.crt" $boldgreen
33+
sleep 9
34+
35+
if [[ -z "$SELFSIGNEDSSL_O" ]]; then
36+
SELFSIGNEDSSL_O="$vhostname"
37+
else
38+
SELFSIGNEDSSL_O="$SELFSIGNEDSSL_O"
39+
fi
40+
41+
if [[ -z "$SELFSIGNEDSSL_OU" ]]; then
42+
SELFSIGNEDSSL_OU="$vhostname"
43+
else
44+
SELFSIGNEDSSL_OU="$SELFSIGNEDSSL_OU"
45+
fi
2946

30-
openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${vhostname}.csr -keyout ${vhostname}.key -subj "/C=US/ST=California/L=Los Angeles/O=${vhostname}/CN=${vhostname}"
47+
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=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${vhostname}"
3148
openssl x509 -req -days 36500 -sha256 -in ${vhostname}.csr -signkey ${vhostname}.key -out ${vhostname}.crt
3249

50+
# echo
51+
# cecho "---------------------------------------------------------------" $boldyellow
52+
# cecho "Generating backup CSR and private key for HTTP Public Key Pinning..." $boldgreen
53+
# cecho "creating CSR File: ${vhostname}-backup.csr" $boldgreen
54+
# cecho "creating private key: ${vhostname}-backup.key" $boldgreen
55+
# sleep 5
56+
57+
# openssl req -new -newkey rsa:2048 -sha256 -nodes -out ${vhostname}-backup.csr -keyout ${vhostname}-backup.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${vhostname}"
58+
59+
# echo
60+
# cecho "---------------------------------------------------------------" $boldyellow
61+
# cecho "Extracting Base64 encoded information for primary and secondary" $boldgreen
62+
# cecho "private key's SPKI - Subject Public Key Information" $boldgreen
63+
# cecho "Primary private key - ${vhostname}.key" $boldgreen
64+
# cecho "Backup private key - ${vhostname}-backup.key" $boldgreen
65+
# cecho "For HPKP - HTTP Public Key Pinning hash generation..." $boldgreen
66+
# sleep 5
67+
68+
# echo
69+
# cecho "extracting SPKI Base64 encoded hash for primary private key = ${vhostname}.key ..." $boldgreen
70+
71+
# openssl rsa -in ${vhostname}.key -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64 | tee -a /usr/local/nginx/conf/ssl/${vhostname}/hpkp-info-primary-pin.txt
72+
73+
# echo
74+
# cecho "extracting SPKI Base64 encoded hash for backup private key = ${vhostname}-backup.key ..." $boldgreen
75+
76+
# openssl rsa -in ${vhostname}-backup.key -outform der -pubout | openssl dgst -sha256 -binary | openssl enc -base64 | tee -a /usr/local/nginx/conf/ssl/${vhostname}/hpkp-info-secondary-pin.txt
77+
78+
# echo
79+
# cecho "HTTP Public Key Pinning Header for Nginx" $boldgreen
80+
81+
# echo
82+
# cecho "for 7 days max-age including subdomains" $boldgreen
83+
# echo
84+
# echo "add_header Public-Key-Pins 'pin-sha256=\"$(cat /usr/local/nginx/conf/ssl/${vhostname}/hpkp-info-primary-pin.txt)\"; pin-sha256=\"$(cat /usr/local/nginx/conf/ssl/${vhostname}/hpkp-info-secondary-pin.txt)\"; max-age=604800; includeSubDomains';"
85+
86+
# echo
87+
# cecho "for 7 days max-age excluding subdomains" $boldgreen
88+
# echo
89+
# echo "add_header Public-Key-Pins 'pin-sha256=\"$(cat /usr/local/nginx/conf/ssl/${vhostname}/hpkp-info-primary-pin.txt)\"; pin-sha256=\"$(cat /usr/local/nginx/conf/ssl/${vhostname}/hpkp-info-secondary-pin.txt)\"; max-age=604800';"
90+
91+
92+
echo
3393
cecho "---------------------------------------------------------------" $boldyellow
3494
cecho "Generating dhparam.pem file - can take a few minutes..." $boldgreen
3595

@@ -162,6 +222,16 @@ else
162222
CHACHACIPHERS=""
163223
fi
164224

225+
if [[ "$(nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then
226+
HTTPTWO=y
227+
LISTENOPT='ssl http2'
228+
COMP_HEADER='#spdy_headers_comp 5'
229+
else
230+
HTTPTWO=n
231+
LISTENOPT='ssl spdy'
232+
COMP_HEADER='spdy_headers_comp 5'
233+
fi
234+
165235
# main non-ssl vhost at yourdomain.com.conf
166236
cat > "/usr/local/nginx/conf/conf.d/$vhostname.conf"<<ENSS
167237
# Centmin Mod Getting Started Guide
@@ -239,7 +309,7 @@ cat > "/usr/local/nginx/conf/conf.d/${vhostname}.ssl.conf"<<ESS
239309
# }
240310

241311
server {
242-
listen 443 ssl spdy;
312+
listen 443 $LISTENOPT;
243313
server_name $vhostname www.$vhostname;
244314

245315
ssl_dhparam /usr/local/nginx/conf/ssl/${vhostname}/dhparam.pem;
@@ -254,7 +324,7 @@ server {
254324
#add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
255325
#add_header X-Content-Type-Options "nosniff";
256326
#add_header X-Frame-Options DENY;
257-
spdy_headers_comp 5;
327+
$COMP_HEADER;
258328
ssl_buffer_size 1400;
259329
ssl_session_tickets on;
260330

@@ -405,6 +475,8 @@ if [[ "$NGINX_VHOSTSSL" = [yY] && "$vhostssl" = [yY] ]]; then
405475
cecho "Self-signed SSL Certificate: /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt" $boldyellow
406476
cecho "SSL Private Key: /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.key" $boldyellow
407477
cecho "SSL CSR File: /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.csr" $boldyellow
478+
# cecho "Backup SSL Private Key: /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-backup.key" $boldyellow
479+
# cecho "Backup SSL CSR File: /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}-backup.csr" $boldyellow
408480
fi
409481
echo
410482
cecho "upload files to /home/nginx/domains/$vhostname/public" $boldwhite
@@ -435,6 +507,7 @@ fi
435507
cecho " rm -rf /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.crt" $boldwhite
436508
cecho " rm -rf /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.key" $boldwhite
437509
cecho " rm -rf /usr/local/nginx/conf/ssl/${vhostname}/${vhostname}.csr" $boldwhite
510+
cecho " rm -rf /usr/local/nginx/conf/ssl/${vhostname}" $boldwhite
438511
cecho " rm -rf /home/nginx/domains/$vhostname" $boldwhite
439512
cecho " service nginx restart" $boldwhite
440513
cecho "-------------------------------------------------------------" $boldyellow

0 commit comments

Comments
 (0)