# Default server definition
server{listen[::]:8080default_server;listen8080default_server;server_name_;sendfileoff;tcp_nodelayon;absolute_redirectoff;# dujiaoka是使用 /app/public为根目录的
root/app/public;indexindex.phpindex.html;location/{# First attempt to serve request as file, then
# as directory, then fall back to index.php
try_files$uri$uri//index.php?q=$uri&$args;}# Redirect server error pages to the static page /50x.html
error_page500502503504/50x.html;location=/50x.html{root/var/lib/nginx/html;}# Pass the PHP scripts to PHP-FPM listening on php-fpm.sock
location~\.php${try_files$uri=404;fastcgi_split_path_info^(.+\.php)(/.+)$;fastcgi_passunix:/run/php-fpm.sock;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;fastcgi_indexindex.php;includefastcgi_params;}# Set the cache-control headers on assets to cache for 5 days
location~*\.(jpg|jpeg|gif|png|css|js|ico|xml)$ {expires5d;}# Deny access to . files, for security
location~/\.{log_not_foundoff;denyall;}# Allow fpm ping and status from localhost
location~^/(fpm-status|fpm-ping)${access_logoff;allow127.0.0.1;denyall;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;fastcgi_passunix:/run/php-fpm.sock;}}
[global]; Log to stderrerror_log=/dev/stderr[www]user=app; The address on which to accept FastCGI requests.; Valid syntaxes are:; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on; a specific port;; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on; a specific port;; 'port' - to listen on a TCP socket to all addresses; (IPv6 and IPv4-mapped) on a specific port;; '/path/to/unix/socket' - to listen on a unix socket.; Note: This value is mandatory.listen=/run/php-fpm.sock; Enable status pagepm.status_path=/fpm-status; Ondemand process managerpm=ondemand; The number of child processes to be created when pm is set to 'static' and the; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'.; This value sets the limit on the number of simultaneous requests that will be; served. Equivalent to the ApacheMaxClients directive with mpm_prefork.; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP; CGI. The below defaults are based on a server without much resources. Don't; forget to tweak pm.* to fit your needs.; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand'; Note: This value is mandatory.pm.max_children=100; The number of seconds after which an idle process will be killed.; Note: Used only when pm is set to 'ondemand'; Default Value: 10spm.process_idle_timeout=10s;; The number of requests each child process should execute before respawning.; This can be useful to work around memory leaks in 3rd party libraries. For; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS.; Default Value: 0pm.max_requests=1000; Make sure the FPM workers can reach the environment variables for configurationclear_env=no; Catch output from PHPcatch_workers_output=yes; Remove the 'child 10 said into stderr' prefix in the log and only show the actual messagedecorate_workers_output=no; Enable ping page to use in healthcheckping.path=/fpm-ping
worker_processesauto;error_logstderrwarn;pid/run/nginx.pid;events{worker_connections1024;}http{includemime.types;# Threat files with a unknown filetype as binary
default_typeapplication/octet-stream;# Define custom log format to include reponse times
log_formatmain_timed'$remote_addr-$remote_user[$time_local]"$request"''$status$body_bytes_sent"$http_referer"''"$http_user_agent""$http_x_forwarded_for"''$request_time$upstream_response_time$pipe$upstream_cache_status';access_log/dev/stdoutmain_timed;error_log/dev/stderrnotice;keepalive_timeout65;# Write temporary files to /tmp so they can be created as a non-privileged user
client_body_temp_path/tmp/client_temp;proxy_temp_path/tmp/proxy_temp_path;fastcgi_temp_path/tmp/fastcgi_temp;uwsgi_temp_path/tmp/uwsgi_temp;scgi_temp_path/tmp/scgi_temp;# Hide headers that identify the server to prevent information leakage
proxy_hide_headerX-Powered-By;fastcgi_hide_headerX-Powered-By;server_tokensoff;# Enable gzip compression by default
gzipon;gzip_proxiedany;# Based on CloudFlare's recommended settings
gzip_typestext/richtexttext/plaintext/csstext/x-scripttext/x-componenttext/x-java-sourcetext/x-markdownapplication/javascriptapplication/x-javascripttext/javascripttext/jsimage/x-iconimage/vnd.microsoft.iconapplication/x-perlapplication/x-httpd-cgitext/xmlapplication/xmlapplication/rss+xmlapplication/vnd.api+jsonapplication/x-protobufapplication/jsonmultipart/bagmultipart/mixedapplication/xhtml+xmlfont/ttffont/otffont/x-woffimage/svg+xmlapplication/vnd.ms-fontobjectapplication/ttfapplication/x-ttfapplication/otfapplication/x-otfapplication/truetypeapplication/opentypeapplication/x-opentypeapplication/font-woffapplication/eotapplication/fontapplication/font-sfntapplication/wasmapplication/javascript-binastapplication/manifest+jsonapplication/ld+jsonapplication/graphql+jsonapplication/geo+json;gzip_varyon;gzip_disable"msie6";# Include server configs
include/etc/nginx/conf.d/*.conf;}