Advertisement
Twissel

nginx config site.ua

May 3rd, 2018
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.06 KB | None | 0 0
  1. server {
  2. listen *:80;
  3. server_name site.ua www.site.ua;
  4. return 301 https://$host$request_uri;
  5. }
  6.  
  7. server {
  8. listen *:443 ssl http2;
  9. server_name site.ua www.site.ua;
  10. if ($host = 'www.site.ua' ) {
  11. return 301 https://site.ua$request_uri;
  12. }
  13. if ( $http_user_agent = "" ){
  14. return 444;
  15. }
  16. keepalive_timeout 75 75;
  17. ssl_prefer_server_ciphers on;
  18. ssl_session_cache shared:SSL:50m;
  19. ssl_session_timeout 1d;
  20. ssl_certificate /etc/letsencrypt/live/site.ua/fullchain.pem;
  21. ssl_certificate_key /etc/letsencrypt/live/site.ua/privkey.pem;
  22. ssl_dhparam /etc/ssl/dhparam.pem;
  23. ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
  24. ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';
  25. add_header Strict-Transport-Security 'max-age=31536000';
  26. ssl_stapling on;
  27. resolver 8.8.4.4 8.8.8.8 valid=300s;
  28. ssl_stapling_verify on;
  29. charset off;
  30. gzip on;
  31. gzip_comp_level 3;
  32. gzip_types application/x-javascript application/javascript text/css;
  33. index index.php;
  34.  
  35.  
  36. access_log /var/log/nginx/site.ua_ssl-access.log;
  37. error_log /var/log/nginx/site.ua_ssl-error.log;
  38.  
  39. ssi on;
  40. set $root_path /var/www/html;
  41. root $root_path;
  42.  
  43. set $php_sock unix:/var/run/php-fpm/php-fpm.sock;
  44.  
  45. proxy_set_header X-Real-IP $remote_addr;
  46. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  47. proxy_set_header Host $host;
  48.  
  49. client_max_body_size 1024M;
  50. client_body_buffer_size 4M;
  51.  
  52. if ($request_uri ~* "^(.*\/)index\.php$") {
  53. return 301 $1;
  54. }
  55. location / {
  56. try_files $uri $uri/ @bitrix;
  57. rewrite ^([^.\?]*[^/])$ $1/ permanent;
  58. }
  59.  
  60.  
  61.  
  62. location ~* /upload/.*\.(php|php3|php4|php5|php6|phtml|pl|asp|aspx|cgi|dll|exe|shtm|shtml|fcg|fcgi|fpl|asmx|pht|py|psp|rb|var)$ {
  63. types {
  64. text/plain text/plain php php3 php4 php5 php6 phtml pl asp aspx cgi dll exe ico shtm shtml fcg fcgi fpl asmx pht py psp rb var;
  65. }
  66. }
  67.  
  68. location ~ \.php$ {
  69. try_files $uri @bitrix;
  70. fastcgi_pass $php_sock;
  71. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  72. fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
  73. fastcgi_read_timeout 300;
  74. include fastcgi_params;
  75. }
  76. location @bitrix {
  77. fastcgi_pass $php_sock;
  78. include fastcgi_params;
  79. fastcgi_param SCRIPT_FILENAME $document_root/bitrix/urlrewrite.php;
  80. fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
  81. }
  82. location ~* /bitrix/admin.+\.php$ {
  83. try_files $uri @bitrixadm;
  84. fastcgi_pass $php_sock;
  85. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  86. fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
  87. include fastcgi_params;
  88. }
  89. location @bitrixadm{
  90. fastcgi_pass $php_sock;
  91. include fastcgi_params;
  92. fastcgi_param SCRIPT_FILENAME $document_root/bitrix/admin/404.php;
  93. fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
  94. }
  95.  
  96. location = /favicon.ico {
  97. log_not_found off;
  98. access_log off;
  99. }
  100.  
  101. location = /robots.txt {
  102. allow all;
  103. log_not_found off;
  104. access_log off;
  105. }
  106. location ~ /.well-known {
  107. allow all;
  108. }
  109. #
  110. # block this locations for any installation
  111. #
  112.  
  113. # ht(passwd|access)
  114. location ~* /\.ht { deny all; }
  115.  
  116. # repositories
  117. location ~* /\.(svn|hg|git) { deny all; }
  118.  
  119. # bitrix internal locations
  120. location ~* ^/bitrix/(modules|local_cache|stack_cache|managed_cache|php_interface) {
  121. deny all;
  122. }
  123. # upload files
  124. location ~* ^/upload/1c_[^/]+/ { deny all; }
  125.  
  126. # use the file system to access files outside the site (cache)
  127. location ~* /\.\./ { deny all; }
  128. location ~* ^/bitrix/html_pages/\.config\.php { deny all; }
  129. location ~* ^/bitrix/html_pages/\.enabled { deny all; }
  130.  
  131. # Intenal locations
  132. location ^~ /upload/support/not_image { internal; }
  133.  
  134. # Cache location: composite and general site
  135. location ~* @.*\.html$ {
  136. internal;
  137. # disable browser cache, php manage file
  138. expires -1y;
  139. add_header X-Bitrix-Composite "Nginx (file)";
  140. }
  141.  
  142. # Player options, disable no-sniff
  143. location ~* ^/bitrix/components/bitrix/player/mediaplayer/player$ {
  144. add_header Access-Control-Allow-Origin *;
  145. }
  146.  
  147. # Accept access for merged css and js
  148. location ~* ^/bitrix/cache/(css/.+\.css|js/.+\.js)$ {
  149. expires 30d;
  150. error_page 404 /404.html;
  151. }
  152.  
  153. # Disable access for other assets in cache location
  154. location ~* ^/bitrix/cache { deny all; }
  155.  
  156. # Use nginx to return static content from s3 cloud storage
  157. # /upload/bx_cloud_upload/<schema>.<backet_name>.<s3_point>.amazonaws.com/<path/to/file>
  158. location ^~ /upload/bx_cloud_upload/ {
  159. location ~ ^/upload/bx_cloud_upload/(http[s]?)\.([^/:]+)\.(s3|s3-us-west-1|s3-eu-west-1|s3-ap-southeast-1|s3-ap-northeast-1)\.amazonaws\.com/(.+)$ {
  160. internal;
  161. resolver 8.8.8.8;
  162. proxy_method GET;
  163. proxy_set_header X-Real-IP $remote_addr;
  164. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  165. proxy_set_header X-Forwarded-Server $host;
  166. #proxy_max_temp_file_size 0;
  167. proxy_pass $1://$2.$3.amazonaws.com/$4;
  168. }
  169. location ~* .*$ { deny all; }
  170. }
  171. # Static content
  172. location ~* ^/(upload|bitrix/images|bitrix/tmp) {
  173. expires 30d;
  174. }
  175.  
  176. location ~* \.(css|js|gif|png|jpg|jpeg|ico|ogg|ttf|woff|eot|otf)$ {
  177. error_page 404 /404.html;
  178. expires 30d;
  179. }
  180.  
  181. location = /404.html {
  182. access_log off ;
  183. }
  184.  
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement