From f96701ae6c1da213b61adeff6d21872288b7b357 Mon Sep 17 00:00:00 2001 From: Fabio Ivona Date: Tue, 2 Apr 2024 10:27:59 +0200 Subject: [PATCH] robots management --- app/Containers/Nginx.php | 17 +++++++++++++---- storage/app/env/Laravel | 3 +++ storage/app/env/PlainPhp | 2 ++ storage/app/env/ReverseProxy | 2 ++ storage/app/nginx/nginx.conf | 2 ++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/app/Containers/Nginx.php b/app/Containers/Nginx.php index f43353b..3f5e33c 100644 --- a/app/Containers/Nginx.php +++ b/app/Containers/Nginx.php @@ -139,13 +139,14 @@ public function expose_internal_host(): self } + /** * @param DockerService $service * * @throws DuplicateServiceException * @throws ContainerException */ - public function setup(DockerService $service) + public function setup(DockerService $service): void { if (!empty($this->php_service)) { @@ -164,12 +165,20 @@ public function publish_assets() $this->publish_backend_not_found(); } - protected function publish_nginx_conf() + protected function publish_nginx_conf(): void { - $this->disk()->put(self::PATH_NGINX_CONF, Storage::get(self::PATH_NGINX_CONF)); + $template = Storage::get(self::PATH_NGINX_CONF); + + $this->compile_template($template, [ + 'ROBOTS' => env('ENABLE_ROBOTS', true) + ? '' + : 'add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive"' + ]); + + $this->disk()->put(self::PATH_NGINX_CONF, $template); } - protected function publish_upstream_conf() + protected function publish_upstream_conf(): void { if (!empty($this->php_service)) { $template = Storage::get(self::PATH_UPSTREAM_CONF); diff --git a/storage/app/env/Laravel b/storage/app/env/Laravel index 09fabbd..9964486 100644 --- a/storage/app/env/Laravel +++ b/storage/app/env/Laravel @@ -41,6 +41,9 @@ NGINX_PORT_SSL=443 #NGINX_CACHE_AGE=1y #NGINX_CACHE_FILES="js|css|jpg|jpeg|png|gif|ico|swf|webp|svg" +#ENABLE_ROBOTS=false + + ####################### # MySql # ####################### diff --git a/storage/app/env/PlainPhp b/storage/app/env/PlainPhp index 80139f7..ff00791 100644 --- a/storage/app/env/PlainPhp +++ b/storage/app/env/PlainPhp @@ -42,6 +42,8 @@ NGINX_ROOT=/var/www #NGINX_CACHE_AGE=1y #NGINX_CACHE_FILES="js|css|jpg|jpeg|png|gif|ico|swf|webp|svg" +#ENABLE_ROBOTS=false + ####################### # MySql # ####################### diff --git a/storage/app/env/ReverseProxy b/storage/app/env/ReverseProxy index d6f08aa..8653bd7 100644 --- a/storage/app/env/ReverseProxy +++ b/storage/app/env/ReverseProxy @@ -14,6 +14,8 @@ RECIPE=ReverseProxy NGINX_PORT=80 NGINX_PORT_SSL=443 +#ENABLE_ROBOTS=false + ####################### diff --git a/storage/app/nginx/nginx.conf b/storage/app/nginx/nginx.conf index b5d3c4d..32bef62 100644 --- a/storage/app/nginx/nginx.conf +++ b/storage/app/nginx/nginx.conf @@ -38,4 +38,6 @@ http { client_max_body_size 5G; fastcgi_read_timeout 600; proxy_read_timeout 600; + + [ROBOTS] }