Advertisement
cthulchu

/etc/nginx/bx/conf/bitrix_general.conf

Sep 26th, 2017
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 5.44 KB | None | 0 0
  1. # Main configuration file for site with Bitrix CMS.
  2. # It doesn't contain configuration for .php and /
  3. # as their treatment depends on the type of caching on the site:
  4. # - general cache - default option
  5. # - composite cache + file - can be enabled in the menu
  6. # - composite cache + memcached -  can be enabled in the menu
  7. #
  8.  
  9. # Assign error handler
  10. include bx/conf/errors.conf;
  11.  
  12. # Include im subscrider handlers
  13. include bx/conf/im_subscrider.conf;
  14.  
  15. # Deny external access to critical areas
  16. include bx/conf/bitrix_block.conf;
  17.  
  18. # Intenal locations
  19. location ^~ /upload/support/not_image   { internal; }
  20.  
  21. # Cache location: composite and general site
  22. location ~* @.*\.html$ {
  23.   internal;
  24.   # disable browser cache, php manage file
  25.   expires -1y;
  26.   add_header X-Bitrix-Composite "Nginx (file)";
  27. }
  28.  
  29. # Player options, disable no-sniff
  30. location ~* ^/bitrix/components/bitrix/player/mediaplayer/player$ {
  31.   add_header Access-Control-Allow-Origin *;
  32. }
  33.  
  34. # Process dav request on
  35. # main company
  36. # extranet
  37. # additional departments
  38. # locations that ends with / => directly to apache
  39. location ~ ^(/[^/]+)?(/docs|/workgroups|/company/profile|/bitrix/tools|/company/personal/user|/mobile/webdav|/contacts/personal).*/$ {
  40.   proxy_pass $proxyserver;
  41. }
  42.  
  43. # Add / to request
  44. location ~ ^(/[^/]+)?(/docs|/workgroups|/company/profile|/bitrix/tools|/company/personal/user|/mobile/webdav|/contacts/personal) {
  45.  
  46.   set $addslash "";
  47.   if (-d $request_filename)   { set $addslash "${addslash}Y"; }
  48.   if ($is_args != '?')    { set $addslash "${addslash}Y"; }
  49.   if ($addslash = "YY" )    { proxy_pass $proxyserver$request_uri/; }
  50.  
  51.   proxy_pass $proxyserver;
  52. }
  53.  
  54. # Accept access for merged css and js
  55. location ~* ^/bitrix/cache/(css/.+\.css|js/.+\.js)$ {
  56.   expires 30d;
  57.   error_page 404 /404.html;
  58. }
  59.  
  60. # Disable access for other assets in cache location
  61. location ~* ^/bitrix/cache              { deny all; }
  62.  
  63. # Excange and Outlook
  64. location ~ ^/bitrix/tools/ws_.*/_vti_bin/.*\.asmx$      { proxy_pass $proxyserver; }
  65.  
  66. # Groupdav
  67. location ^~ /bitrix/groupdav.php                        { proxy_pass $proxyserver; }
  68.  
  69. # Use nginx to return static content from s3 cloud storage
  70. # /upload/bx_cloud_upload/<schema>.<backet_name>.<s3_point>.amazonaws.com/<path/to/file>
  71. location ^~ /upload/bx_cloud_upload/ {
  72.  
  73.     location ~ ^/upload/bx_cloud_upload/(http[s]?)\.([^/:\s]+)\.(s3|s3-us-west-1|s3-eu-west-1|s3-ap-southeast-1|s3-ap-northeast-1)\.amazonaws\.com/([^\s]+)$ {
  74.         internal;
  75.         resolver 8.8.8.8;
  76.         proxy_method GET;
  77.         proxy_set_header        X-Real-IP               $remote_addr;
  78.         proxy_set_header        X-Forwarded-For         $proxy_add_x_forwarded_for;
  79.         proxy_set_header        X-Forwarded-Server      $host;
  80.         #proxy_max_temp_file_size 0;
  81.         proxy_pass $1://$2.$3.amazonaws.com/$4;
  82.     }
  83.  
  84.     location ~ ^/upload/bx_cloud_upload/(http[s]?)\.([^/:\s]+)\.([^/:\s]+)\.([^/:\s]+)\.rackcdn\.com/([^\s]+)$ {
  85.         internal;
  86.         resolver 8.8.8.8;
  87.         proxy_method GET;
  88.         proxy_set_header X-Real-IP $remote_addr;
  89.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  90.         proxy_set_header X-Forwarded-Server $host;
  91.         #proxy_max_temp_file_size 0;
  92.         proxy_pass $1://$2.$3.$4.rackcdn.com/$5;
  93.     }
  94.  
  95.     location ~ ^/upload/bx_cloud_upload/(http[s]?)\.([^/:\s]+)\.clodo\.ru\:(80|443)/([^\s]+)$ {
  96.         internal;
  97.         resolver 8.8.8.8;
  98.         proxy_method GET;
  99.         proxy_set_header X-Real-IP $remote_addr;
  100.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  101.         proxy_set_header X-Forwarded-Server $host;
  102.         #proxy_max_temp_file_size 0;
  103.         proxy_pass $1://$2.clodo.ru:$3/$4;
  104.     }
  105.  
  106.     location ~ ^/upload/bx_cloud_upload/(http[s]?)\.([^/:\s]+)\.commondatastorage\.googleapis\.com/([^\s]+)$ {
  107.         internal;
  108.         resolver 8.8.8.8;
  109.         proxy_method GET;
  110.         proxy_set_header X-Real-IP $remote_addr;
  111.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  112.         proxy_set_header X-Forwarded-Server $host;
  113.         #proxy_max_temp_file_size 0;
  114.         proxy_pass $1://$2.commondatastorage.googleapis.com/$3;
  115.     }
  116.  
  117.     location ~ ^/upload/bx_cloud_upload/(http[s]?)\.([^/:\s]+)\.selcdn\.ru/([^\s]+)$ {
  118.         internal;
  119.         resolver 8.8.8.8;
  120.         proxy_method GET;
  121.         proxy_set_header X-Real-IP $remote_addr;
  122.         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  123.         proxy_set_header X-Forwarded-Server $host;
  124.         #proxy_max_temp_file_size 0;
  125.         proxy_pass $1://$2.selcdn.ru/$3;
  126.     }
  127.     location ~* .*$     { deny all; }
  128. }
  129.  
  130. # Static content
  131. location ~* ^/(upload|bitrix/images|bitrix/tmp) {
  132.   expires 30d;
  133. }
  134.  
  135. location  ~* \.(css|js|gif|png|jpg|jpeg|ico|ogg|ttf|woff|eot|otf)$ {
  136.   error_page 404 /404.html;
  137.   expires 30d;
  138. }
  139.  
  140. # Nginx server status page
  141. location ^~ /nginx-status {
  142.   stub_status on;
  143.   allow 127.0.0.0/24;
  144.   deny all;
  145. }
  146.  
  147. # pub & online
  148. # telephony and voximplant
  149. location ~* ^/(pub/|online/|services/telephony/info_receiver.php|/bitrix/tools/voximplant/) {
  150.  
  151.     add_header X-Frame-Options '' always;
  152.     location ~* ^/(pub/imconnector/|pub/imbot.php|services/telephony/info_receiver.php|bitrix/tools/voximplant/) {
  153.         proxy_ignore_client_abort on;
  154.         proxy_pass $proxyserver;
  155.     }
  156.  
  157.     proxy_pass $proxyserver;
  158. }
  159.  
  160. # Bitrix setup script
  161. location ^~ ^(/bitrixsetup\.php)$ { proxy_pass $proxyserver; proxy_buffering off; }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement