@@ -189,7 +189,7 @@ public function getSiteUrl(string $directory): string
189189 /**
190190 * Identify whether a site is for a proxy by reading the host name from its config file.
191191 */
192- public function getProxyHostForSite (string $ site , string $ configContents = null ): ?string
192+ public function getProxyHostForSite (string $ site , ? string $ configContents = null ): ?string
193193 {
194194 $ siteConf = $ configContents ?: $ this ->getSiteConfigFileContents ($ site );
195195
@@ -208,7 +208,7 @@ public function getProxyHostForSite(string $site, string $configContents = null)
208208 /**
209209 * Get the contents of the configuration for the given site.
210210 */
211- public function getSiteConfigFileContents (string $ site , string $ suffix = null ): ?string
211+ public function getSiteConfigFileContents (string $ site , ? string $ suffix = null ): ?string
212212 {
213213 $ config = $ this ->config ->read ();
214214 $ suffix = $ suffix ?: '. ' .$ config ['tld ' ];
@@ -220,7 +220,7 @@ public function getSiteConfigFileContents(string $site, string $suffix = null):
220220 /**
221221 * Get all certificates from config folder.
222222 */
223- public function getCertificates (string $ path = null ): Collection
223+ public function getCertificates (? string $ path = null ): Collection
224224 {
225225 $ path = $ path ?: $ this ->certificatesPath ();
226226
@@ -284,7 +284,7 @@ public function getSites(string $path, Collection $certs): Collection
284284 /**
285285 * Unlink the given symbolic link.
286286 */
287- public function unlink (string $ name = null ): string
287+ public function unlink (? string $ name = null ): string
288288 {
289289 $ name = $ this ->getSiteLinkName ($ name );
290290
@@ -442,8 +442,7 @@ public function secured(): array
442442 public function securedWithDates (): array
443443 {
444444 return collect ($ this ->secured ())->map (function ($ site ) {
445-
446- $ filePath = $ this ->certificatesPath () . '/ ' . $ site . '.crt ' ;
445+ $ filePath = $ this ->certificatesPath ().'/ ' .$ site .'.crt ' ;
447446
448447 $ expiration = $ this ->cli ->run ("openssl x509 -enddate -noout -in $ filePath " );
449448
@@ -473,7 +472,7 @@ public function isSecured(string $site): bool
473472 *
474473 * @see https://github.com/cabforum/servercert/blob/main/docs/BR.md
475474 */
476- public function secure (string $ url , string $ siteConf = null , int $ certificateExpireInDays = 396 , int $ caExpireInYears = 20 ): void
475+ public function secure (string $ url , ? string $ siteConf = null , int $ certificateExpireInDays = 396 , int $ caExpireInYears = 20 ): void
477476 {
478477 // Extract in order to later preserve custom PHP version config when securing
479478 $ phpVersion = $ this ->customPhpVersion ($ url );
@@ -511,7 +510,7 @@ public function renew($expireIn): void
511510
512511 $ this ->secure ($ url , null , $ expireIn );
513512
514- info ('The [ ' . $ url . '] site has been secured with a fresh TLS certificate. ' );
513+ info ('The [ ' . $ url. '] site has been secured with a fresh TLS certificate. ' );
515514 });
516515 }
517516
@@ -669,11 +668,14 @@ public function buildCertificateConf(string $path, string $url): void
669668 /**
670669 * Build the TLS secured Nginx server for the given URL.
671670 */
672- public function buildSecureNginxServer (string $ url , string $ siteConf = null ): string
671+ public function buildSecureNginxServer (string $ url , ? string $ siteConf = null ): string
673672 {
674673 if ($ siteConf === null ) {
674+ $ nginxVersion = str_replace ('nginx version: nginx/ ' , '' , exec ('nginx -v 2>&1 ' ));
675+ $ configFile = version_compare ($ nginxVersion , '1.25.1 ' , '>= ' ) ? 'secure.valet.conf ' : 'secure.valet-legacy.conf ' ;
676+
675677 $ siteConf = $ this ->replaceOldLoopbackWithNew (
676- $ this ->files ->getStub (' secure.valet.conf ' ),
678+ $ this ->files ->getStub ($ configFile ),
677679 'VALET_LOOPBACK ' ,
678680 $ this ->valetLoopback ()
679681 );
@@ -815,8 +817,11 @@ public function proxyCreate(string $url, string $host, bool $secure = false): vo
815817 $ proxyUrl .= '. ' .$ tld ;
816818 }
817819
820+ $ nginxVersion = str_replace ('nginx version: nginx/ ' , '' , exec ('nginx -v 2>&1 ' ));
821+ $ configFile = version_compare ($ nginxVersion , '1.25.1 ' , '>= ' ) ? 'secure.proxy.valet.conf ' : 'secure.proxy.valet-legacy.conf ' ;
822+
818823 $ siteConf = $ this ->replaceOldLoopbackWithNew (
819- $ this ->files ->getStub ($ secure ? ' secure.proxy.valet.conf ' : 'proxy.valet.conf ' ),
824+ $ this ->files ->getStub ($ secure ? $ configFile : 'proxy.valet.conf ' ),
820825 'VALET_LOOPBACK ' ,
821826 $ this ->valetLoopback ()
822827 );
@@ -984,31 +989,31 @@ public function plistPath(): string
984989 /**
985990 * Get the path to Nginx site configuration files.
986991 */
987- public function nginxPath (string $ additionalPath = null ): string
992+ public function nginxPath (? string $ additionalPath = null ): string
988993 {
989994 return $ this ->valetHomePath ().'/Nginx ' .($ additionalPath ? '/ ' .$ additionalPath : '' );
990995 }
991996
992997 /**
993998 * Get the path to the linked Valet sites.
994999 */
995- public function sitesPath (string $ link = null ): string
1000+ public function sitesPath (? string $ link = null ): string
9961001 {
9971002 return $ this ->valetHomePath ().'/Sites ' .($ link ? '/ ' .$ link : '' );
9981003 }
9991004
10001005 /**
10011006 * Get the path to the Valet CA certificates.
10021007 */
1003- public function caPath (string $ caFile = null ): string
1008+ public function caPath (? string $ caFile = null ): string
10041009 {
10051010 return $ this ->valetHomePath ().'/CA ' .($ caFile ? '/ ' .$ caFile : '' );
10061011 }
10071012
10081013 /**
10091014 * Get the path to the Valet TLS certificates.
10101015 */
1011- public function certificatesPath (string $ url = null , string $ extension = null ): string
1016+ public function certificatesPath (? string $ url = null , ? string $ extension = null ): string
10121017 {
10131018 $ url = $ url ? '/ ' .$ url : '' ;
10141019 $ extension = $ extension ? '. ' .$ extension : '' ;
@@ -1092,7 +1097,7 @@ public function replaceSockFile(string $siteConf, string $phpVersion): string
10921097 /**
10931098 * Get configuration items defined in .valetrc for a site.
10941099 */
1095- public function valetRc (string $ siteName , string $ cwd = null ): array
1100+ public function valetRc (string $ siteName , ? string $ cwd = null ): array
10961101 {
10971102 if ($ cwd ) {
10981103 $ path = $ cwd .'/.valetrc ' ;
@@ -1118,7 +1123,7 @@ public function valetRc(string $siteName, string $cwd = null): array
11181123 /**
11191124 * Get PHP version from .valetrc or .valetphprc for a site.
11201125 */
1121- public function phpRcVersion (string $ siteName , string $ cwd = null ): ?string
1126+ public function phpRcVersion (string $ siteName , ? string $ cwd = null ): ?string
11221127 {
11231128 if ($ cwd ) {
11241129 $ oldPath = $ cwd .'/.valetphprc ' ;
0 commit comments