magento.stpl 5.5 KB

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