-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
103 lines (86 loc) · 2.86 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
user nginx;
worker_processes auto;
worker_rlimit_nofile 40960;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# Increase buffer size
client_max_body_size 20M;
client_body_buffer_size 128k;
include /etc/nginx/conf.d/*.conf;
server {
listen 80;
server_name local.magento;
set $MAGE_ROOT /var/www/html;
set $MAGE_MODE developer;
root $MAGE_ROOT/pub;
index index.php;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# Pass PHP scripts to PHP-FPM container
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass magento_php:9000;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_ADMIN_VALUE "error_log=/var/log/nginx/php_errors.log";
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# Set large header buffer sizes
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_busy_buffers_size 64k;
fastcgi_temp_file_write_size 128k;
# Increase FastCGI timeouts
fastcgi_read_timeout 300;
fastcgi_send_timeout 300;
fastcgi_connect_timeout 300;
include fastcgi_params;
}
# Static file delivery
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|webp|avif|eot|otf|ttf|woff|woff2)$ {
expires max;
add_header Cache-Control "public";
try_files $uri $uri/ /index.php$is_args$args;
}
# Bypass the PHP engine for static files
location ^~ /pub/media/ {
root $MAGE_ROOT/pub/;
try_files $uri $uri/ /index.php$is_args$args;
}
location ^~ /pub/static/ {
root $MAGE_ROOT/pub/;
try_files $uri $uri/ /index.php$is_args$args;
expires max;
add_header Cache-Control "public";
access_log off;
}
# Deny direct access to critical directories
location ~* /app/|/includes/|/lib/|/var/|/vendor/|/generated/|/setup/|/dev/|/phpserver/ {
deny all;
}
# Restrict access to dotfiles (e.g., .htaccess)
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# Error pages
error_page 404 500 502 503 504 /errors/503.php;
location = /errors/503.php {
root $MAGE_ROOT/errors/;
}
}
}