user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; keepalive_timeout 10; server { listen 80; set $root_path '/var/www/html'; set $api_path '${root_path}/api/web'; set $frontend_path '${root_path}/frontend/dist'; root $root_path; charset utf-8; client_max_body_size 2M; etag on; location / { alias $frontend_path; index index.html; try_files $uri /index.html =404; } location /api { try_files $uri /api/web/index.php?$args; } location ~* \.php$ { fastcgi_pass app:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SERVER_NAME $host; } # html файлы идут отдельно, для них будет применяться E-Tag кэширование location ~* \.html$ { root $frontend_path; access_log off; } # Раздача статики для frontend с указанием max-кэша. Сброс будет по #hash после ребилда webpackом location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|json|css|zip|rar|eot|ttf|woff|ico) { root $frontend_path; expires max; access_log off; } } }