3
3
# set $MAGE_MODE default; # or production or developer
4
4
#
5
5
# Example configuration:
6
- # upstream fastcgi_backend {
6
+ upstream fastcgi_backend {
7
7
# # use tcp connection
8
8
# # server 127.0.0.1:9000;
9
9
# # or socket
10
- # server unix:/var/run/php5-fpm.sock;
11
- # }
12
- # server {
13
- # listen 80;
14
- # server_name mage.dev;
15
- # set $MAGE_ROOT /var/www/magento2;
16
- # set $MAGE_MODE develop;
10
+ server unix:/var/run/php5-fpm.sock;
11
+ }
12
+
13
+ server {
14
+ listen 80;
15
+ server_name m2.magento.loc;
16
+ set $MAGE_ROOT /var/www/magento2;
17
+ set $MAGE_MODE developer;
17
18
# include /vagrant/magento2/nginx.conf.sample;
18
- # }
19
+ error_log /var/log/nginx/magento-debug.log debug;
20
+
19
21
20
22
root $MAGE_ROOT;
21
23
@@ -48,55 +50,96 @@ location / {
48
50
49
51
50
52
location /static/ {
53
+
51
54
if ($MAGE_MODE = "production") {
52
55
expires max;
53
56
}
57
+
58
+ location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
59
+ add_header Cache-Control "public";
60
+ expires +1y;
61
+
62
+ if (!-f $request_filename) {
63
+ rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
64
+ }
65
+ }
66
+
67
+ location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
68
+ add_header Cache-Control "no-store";
69
+ expires off;
70
+
71
+ if (!-f $request_filename) {
72
+ rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
73
+ }
74
+
75
+ }
76
+
54
77
if (!-f $request_filename) {
55
78
rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
56
79
}
57
80
}
58
81
59
82
location /media/ {
60
- if (!-f $request_filename) {
61
- rewrite / /get.php;
83
+
84
+ location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
85
+ add_header Cache-Control "public";
86
+ expires +1y;
87
+
88
+ if (!-f $request_filename) {
89
+ rewrite / /get.php;
90
+ }
62
91
}
63
- }
64
92
65
- location /media/customer/ {
66
- deny all ;
67
- }
93
+ location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
94
+ add_header Cache-Control "no-store" ;
95
+ expires off;
68
96
69
- location /media/downloadable/ {
70
- deny all;
71
- }
97
+ if (!-f $request_filename) {
98
+ rewrite / /get.php;
99
+ }
100
+ }
72
101
73
- location ~ /media/theme_customization/.*\.xml$ {
74
- deny all;
75
- }
102
+ if (!-f $request_filename) {
103
+ rewrite / /get.php;
104
+ }
105
+ }
76
106
77
- location /errors / {
78
- try_files $uri =404 ;
79
- }
107
+ location /media/customer / {
108
+ deny all ;
109
+ }
80
110
81
- location ~ ^/errors/.*\.(xml|phtml)$ {
82
- deny all;
83
- }
111
+ location /media/downloadable/ {
112
+ deny all;
113
+ }
84
114
85
- location ~ cron\.php {
86
- deny all;
87
- }
115
+ location ~ /media/theme_customization/.*\.xml$ {
116
+ deny all;
117
+ }
88
118
89
- location ~ (index|get|static|report|404|503)\.php$ {
90
- fastcgi_pass fastcgi_backend;
119
+ location /errors/ {
120
+ try_files $uri =404;
121
+ }
91
122
92
- fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
93
- fastcgi_param PHP_VALUE "memory_limit=256M \n max_execution_time=600";
94
- fastcgi_read_timeout 600s;
95
- fastcgi_connect_timeout 600s;
96
- fastcgi_param MAGE_MODE $MAGE_MODE;
123
+ location ~ ^/errors/.*\.(xml|phtml)$ {
124
+ deny all;
125
+ }
97
126
98
- fastcgi_index index.php;
99
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
100
- include fastcgi_params;
127
+ location ~ cron\.php {
128
+ deny all;
129
+ }
130
+
131
+ location ~ (index|get|static|report|404|503)\.php$ {
132
+ fastcgi_pass fastcgi_backend;
133
+
134
+ fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
135
+ fastcgi_param PHP_VALUE "memory_limit=256M \n max_execution_time=600";
136
+ fastcgi_read_timeout 600s;
137
+ fastcgi_connect_timeout 600s;
138
+ fastcgi_param MAGE_MODE $MAGE_MODE;
139
+
140
+ fastcgi_index index.php;
141
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
142
+ include fastcgi_params;
143
+ }
101
144
}
102
- }
145
+ }
0 commit comments