magento2.conf 4.4 KB

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