server { listen 80; index index.php index.html; root /var/www/html/public; # Log to Docker (avoid writing to container FS) access_log /dev/stdout; error_log /dev/stderr warn; client_max_body_size 500M; # Add X-Forwarded-Proto header proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; proxy_set_header Host $host; location / { try_files $uri $uri/ /index.php?$query_string; } # Files Laravel has authorised (X-Accel-Redirect): PHP checks access, then # answers with an empty body and "X-Accel-Redirect: /_accel/", and nginx sends the file itself, Range requests included. # internal: no client can request it directly. On this redirect nginx keeps # only a few upstream headers (Content-Type, Cache-Control, Expires, # Content-Disposition, Set-Cookie, Accept-Ranges), so the CORS ones are # passed on here; an empty value adds no header. location ^~ /_accel/ { internal; alias /var/www/html/storage/app/; add_header Access-Control-Allow-Origin $upstream_http_access_control_allow_origin always; add_header Access-Control-Allow-Credentials $upstream_http_access_control_allow_credentials always; add_header Access-Control-Expose-Headers $upstream_http_access_control_expose_headers always; add_header Vary $upstream_http_vary always; } location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_param HTTP_PROXY ""; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PHP_SELF $fastcgi_script_name$fastcgi_path_info; fastcgi_param SERVER_NAME $host; fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; # Tells the app that /_accel/ exists (above). A server variable, not a # request header, so a client cannot fake it; without it the app streams # files through PHP as before. fastcgi_param X_ACCEL_STORAGE /_accel/; include fastcgi_params; } }