Net-FullAuto
view release on metacpan or search on metacpan
lib/Net/FullAuto/ISets/Local/EmailServer_is.pm view on Meta::CPAN
'__display__');
($stdout,$stderr)=$handle->cmd($sudo."chkconfig --add nginx");
($stdout,$stderr)=$handle->cmd($sudo."chkconfig --level 345 nginx on");
# https://www.digitalocean.com/community/tutorials/
# how-to-secure-nginx-with-let-s-encrypt-on-centos-7
my $make_nginx='./configure --user=www-data '.
'--group=www-data '.
"--prefix=$nginx_path/nginx ".
'--sbin-path=/usr/sbin/nginx '.
"--conf-path=$nginx_path/nginx/nginx.conf ".
'--pid-path=/var/run/nginx.pid '.
'--lock-path=/var/run/nginx.lock '.
'--error-log-path=/var/log/nginx/error.log '.
'--http-log-path=/var/log/nginx/access.log '.
"--with-http_ssl_module --with-pcre=objs/lib/$pcre ".
"--with-zlib=/opt/source/zlib ".
'--with-http_gzip_static_module '.
'--with-http_ssl_module '.
'--with-file-aio '.
'--with-http_realip_module '.
'--without-http_scgi_module '.
'--without-http_uwsgi_module '.
'--with-http_v2_module '.
'--with-openssl=/opt/source/openssl';
($stdout,$stderr)=$handle->cmd($sudo.$make_nginx,'__display__');
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/-Werror //' ./objs/Makefile");
($stdout,$stderr)=$handle->cmd($sudo.'make install','__display__');
# https://www.liberiangeek.net/2015/10/
# how-to-install-self-signed-certificates-on-nginx-webserver/
($stdout,$stderr)=$handle->cmd($sudo."sed -i 's/1024/64/' ".
"$nginx_path/nginx/nginx.conf");
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/worker_processes 1;/worker_processes 2;/' ".
"$nginx_path/nginx/nginx.conf");
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i '0,/root html/{//d;}' $nginx_path/nginx/nginx.conf");
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i '0,/index index.html/{//d;}' $nginx_path/nginx/nginx.conf");
$ad=" root /var/www/html/roundcube;%NL%".
' index index.php index.html index.htm;%NL%'.
' try_files $uri $uri/ /index.php?$args;';
$ad=<<END;
sed -i '1,/location/ {/location/a\\\
$ad
}' $nginx_path/nginx/nginx.conf
END
$handle->cmd_raw($sudo.$ad);
$ad='%NL% location ~ .php$ {'.
'%NL% root /var/www/html/roundcube;'.
'%NL% fastcgi_pass unix:/run/php-fpm/www.sock;'.
'%NL% fastcgi_index index.php;'.
'%NL% fastcgi_param SCRIPT_FILENAME '.
'$document_root$fastcgi_script_name;'.
'%NL% include fastcgi_params;'.
'%NL% }'.
'%NL%'.
'%NL% location /rspamd {'.
'%NL% proxy_pass http://127.0.0.1:11334/;'.
'%NL% proxy_set_header Host $host;'.
'%NL% proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;'.
'%NL% }'.
'%NL%'.
'%NL% location ~ ^/(README.md|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {'.
'%NL% deny all;'.
'%NL% }'.
'%NL%'.
'%NL% location ~ ^/(bin|SQL|config|temp|logs)/ {'.
'%NL% deny all;'.
'%NL% }'.
'%NL%'.
'%NL% location ~ /\. {'.
'%NL% deny all;'.
'%NL% access_log off;'.
'%NL% log_not_found off;'.
'%NL% }%NL%';
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \'/404/a$ad\' $nginx_path/nginx/nginx.conf");
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \'s/%NL%/\'\"`echo \\\\\\n`/g\" ".
"$nginx_path/nginx/nginx.conf");
foreach my $port (443,444,445,443) {
$avail_port=
`true &>/dev/null </dev/tcp/127.0.0.1/$port && echo open || echo closed`;
my $status=$avail_port;
$avail_port=$port;
chomp($status);
last if $status eq 'closed';
}
$ad='client_max_body_size 10M;';
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \'/octet-stream/i$ad\' $nginx_path/nginx/nginx.conf");
my $ngx="$nginx_path/nginx/nginx.conf";
$handle->cmd_raw($sudo.
"sed -i 's/\\(^client_max_body_size 10M;$\\\)/ \\1/' $ngx");
#($stdout,$stderr)=$handle->cmd($sudo.
# "sed -i \'s/^ listen 80/ listen ".
# "\*:$avail_port ssl http2 default_server/\' ".
# $nginx_path."/nginx/nginx.conf");
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i 's/SCRIPT_NAME/PATH_INFO/' ".
$nginx_path."/local/nginx/fastcgi_params");
$ad='# Catalyst requires setting PATH_INFO (instead of SCRIPT_NAME)'.
' to \$fastcgi_script_name';
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \'/PATH_INFO/i$ad\' $nginx_path/nginx/fastcgi_params");
$ad='fastcgi_param SCRIPT_NAME /;';
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \'/PATH_INFO/a$ad\' $nginx_path/nginx/fastcgi_params");
($stdout,$stderr)=$handle->cmd($sudo.
"sed -i \'s/%NL%/\'\"`echo \\\\\\n`/g\" ".
"$nginx_path/nginx/fastcgi_params");
#
# echo-ing/streaming files over ssh can be tricky. Use echo -e
# and replace these characters with thier HEX
# equivalents (use an external editor for quick
# search and replace - and paste back results.
# use copy/paste or cat file and copy/paste results.):
#
# ! - \\x21 ` - \\x60 * - \\x2A
# " - \\x22 \ - \\x5C
( run in 0.539 second using v1.01-cache-2.11-cpan-39bf76dae61 )