Skip to content

Commit

Permalink
Merge pull request #60 from heseya/develop
Browse files Browse the repository at this point in the history
1.5.0
  • Loading branch information
Jędrzej Buliński committed Jun 1, 2022
2 parents aeb062e + 6574ea0 commit 32b8cfc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
6 changes: 6 additions & 0 deletions app/Http/Controllers/ViewController.php
Expand Up @@ -62,6 +62,12 @@ public function show(Request $request, string $client, string $fileName): Respon
$file = $cached;
}

if (preg_match('/^nginx\/(\d+\.)?(\d+\.)?(\*|\d+)$/', $request->server('SERVER_SOFTWARE'))) {
return response(null)
->header('X-Accel-Redirect', "/stream/{$file->path()}")
->header('Content-Type', $file->mimeType());
}

return $file->isStreamable() ? $this->stream($request, $file)
: response($file->binary())
->header('Content-Type', $file->mimeType())
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yaml
Expand Up @@ -6,7 +6,8 @@ services:
dockerfile: Dockerfile-dev
restart: unless-stopped
volumes:
- .:/usr/src/app
- .:/var/www
- ./docker/nginx-app:/etc/nginx/conf.d
command:
- bash
- -c
Expand Down
12 changes: 3 additions & 9 deletions docker/Dockerfile-dev
@@ -1,4 +1,5 @@
FROM php:8.1-apache
FROM escolasoft/php:8.1-nginx
ADD . /var/www/html

RUN apt-get update && apt-get install -y \
libc-client-dev \
Expand All @@ -22,11 +23,4 @@ RUN docker-php-ext-install bcmath

COPY --from=composer /usr/bin/composer /usr/bin/composer

RUN a2enmod rewrite

ENV APACHE_DOCUMENT_ROOT /usr/src/app/public

WORKDIR /usr/src/app

RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
WORKDIR /var/www
27 changes: 27 additions & 0 deletions docker/nginx-app/default.conf
@@ -0,0 +1,27 @@
server {
listen 80;
index index.php index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/public;

location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}

location / {
try_files $uri $uri/ /index.php?$query_string;
gzip_static on;
}

location /stream/ {
internal;
alias /var/www/storage/app/;
}
}
2 changes: 1 addition & 1 deletion makefile
Expand Up @@ -2,4 +2,4 @@ up:
- docker-compose up -d

bash:
- docker exec -it silverbox_app_1 bash
- docker exec -it silverbox_app_1 bash || docker exec -it silverbox-app-1 bash

0 comments on commit 32b8cfc

Please sign in to comment.