magento.tpl 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. server {
  2. listen %ip%:%web_port%;
  3. server_name %domain_idn% %alias_idn%;
  4. root %docroot%/pub;
  5. index index.php;
  6. autoindex off;
  7. charset UTF-8;
  8. error_page 404 403 = /errors/404.php;
  9. add_header "X-UA-Compatible" "IE=Edge";
  10. access_log /var/log/nginx/domains/%domain%.log combined;
  11. access_log /var/log/nginx/domains/%domain%.bytes bytes;
  12. error_log /var/log/nginx/domains/%domain%.error.log error;
  13. # PHP entry point for setup application
  14. location ~* ^/setup($|/) {
  15. root %docroot%;
  16. location ~ ^/setup/index.php {
  17. fastcgi_pass %backend_lsnr%;
  18. fastcgi_index index.php;
  19. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  20. include /etc/nginx/fastcgi_params;
  21. }
  22. location ~ ^/setup/(?!pub/). {
  23. deny all;
  24. }
  25. location ~ ^/setup/pub/ {
  26. add_header X-Frame-Options "SAMEORIGIN";
  27. }
  28. }
  29. # PHP entry point for update application
  30. location ~* ^/update($|/) {
  31. root %docroot%;
  32. location ~ ^/update/index.php {
  33. fastcgi_split_path_info ^(/update/index.php)(/.+)$;
  34. fastcgi_pass %backend_lsnr%;
  35. fastcgi_index index.php;
  36. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  37. fastcgi_param PATH_INFO $fastcgi_path_info;
  38. include /etc/nginx/fastcgi_params;
  39. }
  40. # Deny everything but index.php
  41. location ~ ^/update/(?!pub/). {
  42. deny all;
  43. }
  44. location ~ ^/update/pub/ {
  45. add_header X-Frame-Options "SAMEORIGIN";
  46. }
  47. }
  48. location / {
  49. try_files $uri $uri/ /index.php?$args;
  50. }
  51. location /pub/ {
  52. location ~ ^/pub/media/(downloadable|customer|import|theme_customization/.*\.xml) {
  53. deny all;
  54. }
  55. alias %docroot%/pub/;
  56. add_header X-Frame-Options "SAMEORIGIN";
  57. }
  58. location /static/ {
  59. # Uncomment the following line in production mode
  60. # expires max;
  61. # Remove signature of the static files that is used to overcome the browser cache
  62. location ~ ^/static/version {
  63. rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last;
  64. }
  65. location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  66. add_header Cache-Control "public";
  67. add_header X-Frame-Options "SAMEORIGIN";
  68. expires +1y;
  69. if (!-f $request_filename) {
  70. rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  71. }
  72. }
  73. location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  74. add_header Cache-Control "no-store";
  75. add_header X-Frame-Options "SAMEORIGIN";
  76. expires off;
  77. if (!-f $request_filename) {
  78. rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  79. }
  80. }
  81. if (!-f $request_filename) {
  82. rewrite ^/static/(version\d*/)?(.*)$ /static.php?resource=$2 last;
  83. }
  84. add_header X-Frame-Options "SAMEORIGIN";
  85. }
  86. location /media/ {
  87. try_files $uri $uri/ /get.php?$args;
  88. location ~ ^/media/theme_customization/.*\.xml {
  89. deny all;
  90. }
  91. location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2)$ {
  92. add_header Cache-Control "public";
  93. add_header X-Frame-Options "SAMEORIGIN";
  94. expires +1y;
  95. try_files $uri $uri/ /get.php?$args;
  96. }
  97. location ~* \.(zip|gz|gzip|bz2|csv|xml)$ {
  98. add_header Cache-Control "no-store";
  99. add_header X-Frame-Options "SAMEORIGIN";
  100. expires off;
  101. try_files $uri $uri/ /get.php?$args;
  102. }
  103. add_header X-Frame-Options "SAMEORIGIN";
  104. }
  105. location /media/customer/ {
  106. deny all;
  107. }
  108. location /media/downloadable/ {
  109. deny all;
  110. }
  111. location /media/import/ {
  112. deny all;
  113. }
  114. # PHP entry point for main application
  115. location ~ (index|get|static|report|404|503)\.php$ {
  116. try_files $uri =404;
  117. fastcgi_pass %backend_lsnr%;
  118. fastcgi_buffers 1024 4k;
  119. fastcgi_read_timeout 600s;
  120. fastcgi_connect_timeout 600s;
  121. fastcgi_index index.php;
  122. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  123. include /etc/nginx/fastcgi_params;
  124. }
  125. gzip on;
  126. gzip_disable "msie6";
  127. gzip_comp_level 6;
  128. gzip_min_length 1100;
  129. gzip_buffers 16 8k;
  130. gzip_proxied any;
  131. gzip_types
  132. text/plain
  133. text/css
  134. text/js
  135. text/xml
  136. text/javascript
  137. application/javascript
  138. application/x-javascript
  139. application/json
  140. application/xml
  141. application/xml+rss
  142. image/svg+xml;
  143. gzip_vary on;
  144. # Banned locations (only reached if the earlier PHP entry point regexes don't match)
  145. location ~* (\.php$|\.htaccess$|\.git) {
  146. deny all;
  147. }
  148. location /vstats/ {
  149. alias %home%/%user%/web/%domain%/stats/;
  150. include %home%/%user%/conf/web/%domain%.auth*;
  151. }
  152. include /etc/nginx/conf.d/phpmyadmin.inc*;
  153. include /etc/nginx/conf.d/phppgadmin.inc*;
  154. include /etc/nginx/conf.d/webmail.inc*;
  155. include %home%/%user%/conf/web/nginx.%domain%.conf*;
  156. }