fix letsencrypt for aliases & blank php deployment fix (#204)

This commit is contained in:
Saeed Vaziry 2024-05-13 00:37:51 +02:00 committed by GitHub
parent 88223a61f9
commit 30ef8ad5eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 19 additions and 40 deletions

View File

@ -6,6 +6,7 @@
use App\Enums\SslType;
use App\Models\Site;
use App\Models\Ssl;
use App\SSH\Services\Webserver\Webserver;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rule;
use Illuminate\Validation\ValidationException;
@ -30,11 +31,16 @@ public function create(Site $site, array $input): void
$ssl->save();
dispatch(function () use ($site, $ssl) {
$site->server->webserver()->handler()->setupSSL($ssl);
/** @var Webserver $webserver */
$webserver = $site->server->webserver()->handler();
$webserver->setupSSL($ssl);
$ssl->status = SslStatus::CREATED;
$ssl->save();
$site->type()->edit();
});
})->catch(function () use ($ssl) {
$ssl->status = SslStatus::FAILED;
$ssl->save();
})->onConnection('ssh');
}
/**

View File

@ -30,7 +30,7 @@ public function run(Site $site): Deployment
'deployment_script_id' => $site->deploymentScript->id,
'status' => DeploymentStatus::DEPLOYING,
]);
$lastCommit = $site->sourceControl()->provider()->getLastCommit($site->repository, $site->branch);
$lastCommit = $site->sourceControl()?->provider()?->getLastCommit($site->repository, $site->branch);
if ($lastCommit) {
$deployment->commit_id = $lastCommit['commit_id'];
$deployment->commit_data = $lastCommit['commit_data'];

View File

@ -117,9 +117,16 @@ public function changePHPVersion(Site $site, $version): void
*/
public function setupSSL(Ssl $ssl): void
{
$domains = '-d '.$ssl->site->domain;
if ($ssl->site->aliases) {
foreach ($ssl->site->aliases as $alias) {
$domains .= ' -d '.$alias;
}
}
$command = $this->getScript('nginx/create-letsencrypt-ssl.sh', [
'email' => $ssl->site->server->creator->email,
'domain' => $ssl->site->domain,
'domains' => $domains,
'web_directory' => $ssl->site->getWebDirectoryPath(),
]);
if ($ssl->type == 'custom') {

View File

@ -1,3 +1,3 @@
if ! sudo certbot certonly --force-renewal --nginx --noninteractive --agree-tos --cert-name __domain__ -m __email__ -d __domain__ --verbose; then
if ! sudo certbot certonly --force-renewal --nginx --noninteractive --agree-tos --cert-name __domain__ -m __email__ __domains__ --verbose; then
echo 'VITO_SSH_ERROR' && exit 1
fi

View File

@ -1,10 +1,9 @@
server {
listen 80;
listen 443 ssl;
server_name __domain__ www.__domain__;
server_name __domain__ __aliases__;
root __path__/__web_directory__;
ssl on;
ssl_certificate __certificate__;
ssl_certificate_key __private_key__;

View File

@ -1,6 +1,6 @@
server {
listen 80;
server_name __domain__ www.__domain__;
server_name __domain__ __aliases__;
root __path__/__web_directory__;
add_header X-Frame-Options "SAMEORIGIN";

View File

@ -1,31 +0,0 @@
server {
listen __port__;
server_name _;
root /home/vito/phpmyadmin;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php__php_version__-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}

View File

@ -4,7 +4,6 @@ server {
server_name __domain__ __aliases__;
root __path__;
ssl on;
ssl_certificate __certificate__;
ssl_certificate_key __private_key__;

View File

@ -4,7 +4,6 @@ server {
server_name __domain__ __aliases__;
root __path__/__web_directory__;
ssl on;
ssl_certificate __certificate__;
ssl_certificate_key __private_key__;