46 lines
1.8 KiB
PHP
46 lines
1.8 KiB
PHP
<?php
|
|
if(($_GET['k']??'')!=='WEVADS2026') die('auth');
|
|
$results=[];
|
|
|
|
// Add nginx proxy locations to main site config
|
|
$conf="/etc/nginx/sites-available/weval-consulting.com";
|
|
$c=file_get_contents($conf);
|
|
|
|
// Scrapy dashboard: /scrapy/
|
|
if(strpos($c,"location /scrapy")===false){
|
|
$block="\n # Scrapy API\n location /scrapy/ {\n alias /opt/weval-scrapy/;\n index index.html;\n }\n";
|
|
// Add before last }
|
|
$pos=strrpos($c,"}");
|
|
if($pos) $c=substr($c,0,$pos).$block.substr($c,$pos);
|
|
$results[]="scrapy proxy added";
|
|
}
|
|
|
|
// MiroFish: /mirofish/ → port 5010
|
|
if(strpos($c,"location /mirofish")===false){
|
|
$block="\n # MiroFish\n location /mirofish/ {\n proxy_pass http://127.0.0.1:5010/;\n proxy_set_header Host \$host;\n proxy_http_version 1.1;\n proxy_set_header Upgrade \$http_upgrade;\n proxy_set_header Connection \"upgrade\";\n }\n";
|
|
$pos=strrpos($c,"}");
|
|
if($pos) $c=substr($c,0,$pos).$block.substr($c,$pos);
|
|
$results[]="mirofish proxy added";
|
|
}
|
|
|
|
// Paperclip: /paperclip/ → port 3150
|
|
if(strpos($c,"location /paperclip")===false){
|
|
$block="\n # Paperclip\n location /paperclip/ {\n proxy_pass http://127.0.0.1:3150/;\n proxy_set_header Host \$host;\n proxy_http_version 1.1;\n proxy_set_header Upgrade \$http_upgrade;\n proxy_set_header Connection \"upgrade\";\n }\n";
|
|
$pos=strrpos($c,"}");
|
|
if($pos) $c=substr($c,0,$pos).$block.substr($c,$pos);
|
|
$results[]="paperclip proxy added";
|
|
}
|
|
|
|
if(count($results)>0){
|
|
file_put_contents($conf,$c);
|
|
$test=exec("nginx -t 2>&1");
|
|
if(strpos($test,"successful")!==false){
|
|
exec("nginx -s reload");
|
|
$results[]="nginx reloaded OK";
|
|
} else {
|
|
$results[]="nginx test FAILED: $test";
|
|
}
|
|
}
|
|
|
|
echo json_encode(["ok"=>true,"results"=>$results]);
|