laravel / forge-sdk

The official Laravel Forge PHP SDK.
https://forge.laravel.com
MIT License
521 stars 86 forks source link

CreateSite api isolation=true goes on 502 error #132

Closed ghena closed 2 years ago

ghena commented 2 years ago

Description:

Using CreateSite method and isolation = true website goes on 502 error.

Steps To Reproduce:

Create Site

$siteParams = [ "domain" => $siteSlug .".socialdrinks.it", "project_type" => "php", "directory" => "/public", "isolated" => true, "php_version" => "php74" ];

$forge = new Laravel\Forge\Forge($token,$guzzleClient); $forge->createSite($serverId, $siteParams,false);

Site is created but the website response is 502 bad gateway.

regards. .g

jbrooksuk commented 2 years ago

You also need to pass through a username when the site is isolated. We're going to deploy a fix for this validation here.

Can you email forge@laravel.com and include the server and site ID, please?

ghena commented 2 years ago

I sent already a ticket to forge. the username must be related to the directory or not ?

jbrooksuk commented 2 years ago

You can set the username to whatever anything except:

tfevens commented 2 years ago

I've not been able to recreate the issue experienced. Issuing the command from the SDK is resulting in the site being created, and data returned properly.

$forge = new \Laravel\Forge\Forge(env('FORGE_API_KEY'));
    $site = $forge->createSite($serverId, [
    "domain" => "testsite.com",
    "project_type" => "php",
    "directory" => "/public",
    "isolated" => true,
    "php_version" => "php73"
  ]);
  dump($site);

returns

Laravel\Forge\Resources\Site {#648
  +id: 1493280
  +serverId: [redacted]
  +name: "testsite.com"
  +aliases: []
  +directory: "/public"
  +status: "installed"
  +projectType: "php"
  +username: "forge"
  [...]
}

It seems that if username is left off the request, that a default of forge is used to create the site anyway.

ghena commented 2 years ago

yes but the website goes on error or not ?

ghena commented 2 years ago

however , using username seems to work.

tfevens commented 2 years ago

@ghena I did not get an error when username was left empty.

ghena commented 2 years ago

@ghena I did not get an error when username was left empty.

have you tried using a subdomain ?

tfevens commented 2 years ago

have you tried using a subdomain ?

I hadn't, but just tried it - worked without error again.

$forge = new \Laravel\Forge\Forge(env('FORGE_API_KEY'));
$site = $forge->createSite($serverId, [
  "domain" => "demo2.testsite.com",
  "project_type" => "php",
  "directory" => "/public",
  "isolated" => true,
  "php_version" => "php73"
]);
dump($site);

gives

Laravel\Forge\Resources\Site {#648 
  +id: 1493981
  +serverId: [redacted]
  +name: "demo2.testsite.com"
  +aliases: []
  +directory: "/public"
  +status: "installed"
  +projectType: "php"
  +username: "forge"

It's possible that the Forge team deployed a fix already, but as long as you can get it working, that's the main thing!

shaxzodbek-uzb commented 1 year ago

same issue even on isolated false Nginx is ok but php says: [14-Jul-2023 16:14:58] NOTICE: Terminating ... [14-Jul-2023 16:14:58] NOTICE: exiting, bye-bye! [14-Jul-2023 16:14:58] NOTICE: fpm is running, pid 9140 [14-Jul-2023 16:14:58] NOTICE: ready to handle connections [14-Jul-2023 16:14:58] NOTICE: systemd monitor interval set to 10000ms