diff --git a/app/Factories/NginxVhostFactory.php b/app/Factories/NginxVhostFactory.php index 9562e23..0776c0b 100644 --- a/app/Factories/NginxVhostFactory.php +++ b/app/Factories/NginxVhostFactory.php @@ -91,12 +91,12 @@ class NginxVhostFactory ->disableDefaultItems() // edit configuration - ->addItem('edit', function(CliMenu $menu) use ($vhost) { + ->addItem('edit', function(CliMenu $menu) use (&$vhost) { system('nano /etc/nginx/sites-available/'.$vhost['file'].' > `tty`'); }) // delete configuration - ->addItem('delete', function(CliMenu $menu) use ($vhost) { + ->addItem('delete', function(CliMenu $menu) use (&$vhost) { if ($vhost['enabled'] === true) { $menu->flash('Please disable first!')->display(); @@ -166,10 +166,10 @@ class NginxVhostFactory * @param [type] $vhost * @return [type] */ - private function createVhostCheckbox($vhost) + private function createVhostCheckbox(&$vhost) { // create checkbox for enabled / disabled - $checkbox = new CheckboxItem('enabled', function(CliMenu $menu) use ($vhost) { + $checkbox = new CheckboxItem('enabled', function(CliMenu $menu) use (&$vhost) { // check status if ($menu->getSelectedItem()->getChecked()) { diff --git a/resources/nginx/templates/flight.blade.php b/resources/nginx/templates/flight.blade.php index 232036f..2f8e117 100644 --- a/resources/nginx/templates/flight.blade.php +++ b/resources/nginx/templates/flight.blade.php @@ -6,13 +6,13 @@ index {{ $index }}; location / { - try_files $uri $uri/ /index.php; + try_files $uri $uri/ /{{ $index }}; } # php-fpm configuration. location ~ \.php(/|$) { fastcgi_split_path_info ^(.+\.php)(.*)$; - fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; + fastcgi_pass unix:/var/run/php/{{ $phpFpm }}.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; fastcgi_param DOCUMENT_ROOT $realpath_root; diff --git a/resources/nginx/templates/laravel.blade.php b/resources/nginx/templates/laravel.blade.php index 7931acb..f881bd2 100644 --- a/resources/nginx/templates/laravel.blade.php +++ b/resources/nginx/templates/laravel.blade.php @@ -1 +1,26 @@ -@extends($ssl ? 'layouts.ssl' : 'layouts.no-ssl') \ No newline at end of file +@extends($ssl ? 'layouts.ssl' : 'layouts.no-ssl') + +@section('server') + + root {{ $root }}; + index {{ $index }}; + + location / { + try_files $uri $uri/ /{{ $index }}?$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; + + # php-fpm configuration. + location ~ \.php(/|$) { + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_pass unix:/var/run/php/{{ $phpFpm }}.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + include /etc/nginx/fastcgi_params; + } +@endsection \ No newline at end of file diff --git a/resources/nginx/templates/layouts/ssl.blade.php b/resources/nginx/templates/layouts/ssl.blade.php index cf58613..628da7c 100644 --- a/resources/nginx/templates/layouts/ssl.blade.php +++ b/resources/nginx/templates/layouts/ssl.blade.php @@ -13,7 +13,7 @@ server { ssl_certificate /etc/letsencrypt/live/www.{{ $domain }}/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/www.{{ $domain }}/privkey.pem; - include snippets/ssl-params.conf; + include /etc/nginx/snippets/snippets/ssl-params.conf; include /etc/nginx/snippets/secure-headers.conf; server_name www.{{ $domain }}; @@ -28,6 +28,9 @@ server { ssl_certificate /etc/letsencrypt/live/{{ $domain }}/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/{{ $domain }}/privkey.pem; + include /etc/nginx/snippets/snippets/ssl-params.conf; + include /etc/nginx/snippets/secure-headers.conf; + add_header Content-Security-Policy " default-src 'self'; font-src 'self'; diff --git a/resources/nginx/templates/php.blade.php b/resources/nginx/templates/php.blade.php index 7931acb..2f8e117 100644 --- a/resources/nginx/templates/php.blade.php +++ b/resources/nginx/templates/php.blade.php @@ -1 +1,21 @@ -@extends($ssl ? 'layouts.ssl' : 'layouts.no-ssl') \ No newline at end of file +@extends($ssl ? 'layouts.ssl' : 'layouts.no-ssl') + +@section('server') + + root {{ $root }}; + index {{ $index }}; + + location / { + try_files $uri $uri/ /{{ $index }}; + } + + # php-fpm configuration. + location ~ \.php(/|$) { + fastcgi_split_path_info ^(.+\.php)(.*)$; + fastcgi_pass unix:/var/run/php/{{ $phpFpm }}.sock; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; + fastcgi_param DOCUMENT_ROOT $realpath_root; + include /etc/nginx/fastcgi_params; + } +@endsection \ No newline at end of file diff --git a/resources/nginx/templates/reverse-proxy.blade.php b/resources/nginx/templates/reverse-proxy.blade.php deleted file mode 100644 index 67a1359..0000000 --- a/resources/nginx/templates/reverse-proxy.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -@extends($ssl ? 'layouts.ssl' : 'layouts.no-ssl') - -@section('server') - -@endsection \ No newline at end of file