diff --git a/CHANGELOG.md b/CHANGELOG.md index 264bbf3..2d0362c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## [2.0.3] - 2020-01-27 + +### Added + +- Added new before start check, when prerender host (option `server.prerender.host`) is fill and has a valid url address. + +### Changed + +None. + +### Removed + +None. + ## [2.0.2] - 2020-01-27 ### Added diff --git a/README.md b/README.md index d734516..313075c 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Server created for javascript SPA apps like: Vue, React, Angular, etc. ## Docker usage ```Dockerfile -FROM microparts/static-server-php:2.0.2 +FROM microparts/static-server-php:2.0.3 ARG VCS_SHA1 ARG STAGE @@ -45,7 +45,7 @@ server run Result: ```bash -[2019-12-18 17:38:30] Server.INFO: State: STAGE=local SHA1= VERSION=2.0.2 CONFIG_PATH=/Users/roquie/google_drive/projects/microparts/static-server-php/configuration +[2019-12-18 17:38:30] Server.INFO: State: STAGE=local SHA1= VERSION=2.0.3 CONFIG_PATH=/Users/roquie/google_drive/projects/microparts/static-server-php/configuration [2019-12-18 17:38:30] Server.INFO: Files modification enabled. Have fun!. [2019-12-18 17:38:30] Server.INFO: Nginx Brotli module not installed. Turning off this compression method. [2019-12-18 17:38:30] Server.INFO: Check if platform supports async io... @@ -68,7 +68,7 @@ server reload Reload command result: ```bash [2019-12-18 17:41:44] Server.INFO: Reload configuration -[2019-12-18 17:41:44] Server.INFO: State: STAGE=local SHA1= VERSION=2.0.2 CONFIG_PATH=/Users/roquie/google_drive/projects/microparts/static-server-php/configuration +[2019-12-18 17:41:44] Server.INFO: State: STAGE=local SHA1= VERSION=2.0.3 CONFIG_PATH=/Users/roquie/google_drive/projects/microparts/static-server-php/configuration [2019-12-18 17:41:44] Server.INFO: Files modification enabled. Have fun!. [2019-12-18 17:41:44] Server.INFO: Nginx Brotli module not installed. Turning off this compression method. [2019-12-18 17:41:44] Server.INFO: Check if platform supports async io... diff --git a/src/Application.php b/src/Application.php index 3ce664e..97f183f 100644 --- a/src/Application.php +++ b/src/Application.php @@ -22,7 +22,7 @@ final class Application { - public const VERSION = '2.0.2'; + public const VERSION = '2.0.3'; private const SERVER_LOG_CHANNEL = 'Server'; private Configuration $conf; diff --git a/src/Handler/NginxHandler.php b/src/Handler/NginxHandler.php index feb386f..4ef9cf1 100644 --- a/src/Handler/NginxHandler.php +++ b/src/Handler/NginxHandler.php @@ -61,6 +61,7 @@ public function checkDependenciesBeforeStart(): void $this->checkIfBrotliModuleInstalled(); $this->checkIfPlatformSupportsAsyncIo(); $this->checkIfPrerenderUrlIsAvailable(); + $this->checkIfPrerenderHostIsNotEmpty(); } /** @@ -198,6 +199,27 @@ private function checkIfPrerenderUrlIsAvailable(): void $this->logger->warning('Prerender url could not be reached: ' . $url); } + private function checkIfPrerenderHostIsNotEmpty(): void + { + if (!$this->configuration->get('server.prerender.enabled', false)) { + return; + } + + $this->logger->info('Checks prerender host is fill and has a valid url address...'); + + $host = $this->configuration->get('server.prerender.host', ''); + + if (strlen($host) < 1) { + throw new InvalidArgumentException('Prerender host is empty. Check server.prerender.host config key.'); + } + + $valid = (bool) parse_url($host); + + if (!$valid) { + throw new InvalidArgumentException('Prerender host is invalid (can\'t parse a url). Check server.prerender.host config key.'); + } + } + /** * @return void */ diff --git a/src/Handler/templates/nginx_default.conf.php b/src/Handler/templates/nginx_default.conf.php index 0d2757b..de9d838 100644 --- a/src/Handler/templates/nginx_default.conf.php +++ b/src/Handler/templates/nginx_default.conf.php @@ -287,6 +287,7 @@ #setting prerender as a variable forces DNS resolution since nginx caches IPs and doesnt play well with load balancing rewrite .* /$request_uri?$query_string break; proxy_pass ""; + break; } if ($prerender = 0) {