function build_default($aspid = false) { $sock = new sockets(); $unix = new unix(); if (!$aspid) { $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid"; $pid = $unix->get_pid_from_file($pidfile); if ($unix->process_exists($pid, basename(__FILE__))) { $time = $unix->PROCCESS_TIME_MIN($pid); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, Already Artica task running PID {$pid} since {$time}mn\n"; } return; } @file_put_contents($pidfile, getmypid()); } $unix = new unix(); $hostname = $unix->hostname_g(); if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Hostname {$hostname}\n"; } $EnableFreeWeb = $sock->GET_INFO("EnableFreeWeb"); @unlink("/etc/nginx/conf.d/default.conf"); if (!is_numeric($EnableFreeWeb)) { $EnableFreeWeb = 0; } if ($EnableFreeWeb == 0) { if ($GLOBALS["OUTPUT"]) { echo "Starting......: " . date("H:i:s") . " [INIT]: Hostname {$hostname} FreeWeb is disabled\n"; } return; } $f[] = "server {"; $f[] = "\tlisten 80;"; $f[] = "\tserver_name " . $unix->hostname_g() . ";"; $f[] = "\tproxy_cache_key \$host\$request_uri\$cookie_user"; $f[] = "\tproxy_set_header Host \$host;"; $f[] = "\tproxy_set_header\tX-Forwarded-For\t\$proxy_add_x_forwarded_for;"; $f[] = "\tproxy_set_header\tX-Real-IP\t\$remote_addr;"; $f[] = "\tlocation /nginx_status {"; $f[] = "\tstub_status on;"; $f[] = "\taccess_log off;"; $f[] = "\tallow 127.0.0.1;"; $f[] = "\tdeny all;"; $f[] = "}"; $squidR = new squidbee(); $nginx = new nginx(); $f[] = "\tlocation / {"; $f[] = "\t\tproxy_pass http://127.0.0.1:82;"; $f[] = "\t}"; $f[] = "}\n"; $f[] = "server {"; $f[] = "\tlisten 443;"; $f[] = "\tkeepalive_timeout 70;"; $f[] = "\tssl on;"; $f[] = "\t" . $squidR->SaveCertificate($unix->hostname_g(), false, true); $f[] = "\tssl_session_timeout 5m;"; $f[] = "\tssl_protocols SSLv3 TLSv1;"; $f[] = "\tssl_ciphers HIGH:!aNULL:!MD5;"; $f[] = "\tssl_prefer_server_ciphers on;"; $f[] = "\tserver_name " . $unix->hostname_g() . ";"; $f[] = "\tproxy_cache_key \$host\$request_uri\$cookie_user;"; $f[] = "\tproxy_set_header Host \$host;"; $f[] = "\tproxy_set_header\tX-Forwarded-For\t\$proxy_add_x_forwarded_for;"; $f[] = "\tproxy_set_header\tX-Real-IP\t\$remote_addr;"; $f[] = "\tlocation /nginx_status {"; $f[] = "\tstub_status on;"; $f[] = "\taccess_log off;"; $f[] = "\tallow 127.0.0.1;"; $f[] = "\tdeny all;"; $f[] = "}"; $nginx = new nginx(); $f[] = $nginx->webdav_containers(); $f[] = "\tlocation / {"; $f[] = "\t\tproxy_pass http://127.0.0.1:82;"; $f[] = "\t}"; $f[] = "}\n"; @file_put_contents("/etc/nginx/conf.d/default.conf", @implode("\n", $f)); if ($GLOBALS["RELOAD"]) { reload(true); } }