Advertisement
Guest User

Untitled

a guest
Nov 1st, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Nginx 5.35 KB | None | 0 0
  1. /etc/nginx/nginx.conf
  2. user www;
  3. worker_processes 2;
  4. worker_rlimit_nofile 16392;
  5.  
  6. pid /var/run/nginx.pid;
  7.  
  8. events {
  9.   worker_connections 1024;
  10.   use epoll;
  11.   multi_accept on;
  12. }
  13.  
  14. http {
  15.   sendfile on;
  16.   tcp_nopush on;
  17.   tcp_nodelay off;
  18.   port_in_redirect off;
  19.   server_tokens off;
  20.   server_names_hash_bucket_size 128;
  21.   types_hash_max_size 16392;
  22.   map_hash_bucket_size 128;
  23.   client_header_timeout 10;
  24.   send_timeout 10;
  25.   client_max_body_size 200M;
  26.   client_body_buffer_size 8M;
  27.  
  28.   # --- file cache ---
  29.   open_file_cache max=1024 inactive=20s;
  30.   open_file_cache_valid 30s;
  31.   open_file_cache_min_uses 2;
  32.   open_file_cache_errors on;
  33.  
  34.   # --- Defaults ---
  35.   default_type text/html;
  36.   index index.php index.html index.htm;
  37.  
  38.   # --- Mime-type table ---
  39.   include mime.types;
  40.  
  41.   # --- SSL ---
  42.   ssl_prefer_server_ciphers on;
  43.   ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
  44.   ssl_session_cache shared:SSL:10m;
  45.   ssl_session_timeout 10m;
  46.   ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA:AES128-GCM-SHA256:AES128-SHA:HIGH:!ADH:!EXP:!LOW:!RC2:!3DES:!SEED:!MD5:!aNULL:!EDH:!CAMELLIA:!MEDIUM:!RC4:!eNULL;
  47.  
  48.   # --- Logging ---
  49.   log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" $request_time';
  50.   log_format blocked '$time_local: Blocked request from $remote_addr $request';
  51.   log_format post '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" $request_time $upstream_response_time $body_bytes_sent $request_body';
  52.   access_log syslog:server=unix:/dev/log,facility=local7,tag=nginx,severity=notice;
  53.   error_log syslog:server=unix:/dev/log,facility=local7,tag=nginx,severity=error;
  54.  
  55.   # --- Gzip ---
  56.   gzip on;
  57.   gzip_disable "msie6";
  58.   gzip_vary on;
  59.   gzip_min_length 100;
  60.   gzip_http_version 1.1;
  61.   gzip_comp_level 1;
  62.   gzip_proxied any;
  63.   gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml application/xml+rss application/json image/svg+xml;
  64.   gzip_buffers 128 16k;
  65.  
  66.   # --- memcached servers ---
  67.   upstream memcached {
  68.     server unix:/var/run/memcached/memcached.sock;
  69.   }
  70.  
  71.   # --- PHP-FPM ---
  72.   upstream php-fpm {
  73.     server unix:/var/run/php5-fpm.sock;
  74.   }
  75.  
  76.   server {
  77.     listen 80 default_server;
  78.     server_name __;
  79.     root /var/www/;
  80.  
  81.     set $memcached_raw_key $scheme://$host$request_uri;
  82.     set $memcached_key data-$memcached_raw_key;
  83.     set $memcached_request 0;
  84.  
  85.     if ($request_method = POST ) {
  86.       set $memcached_request 0;
  87.     }
  88.  
  89.     if ( $uri ~ "/wp-" ) {
  90.       set $memcached_request 0;
  91.     }
  92.  
  93.     if ( $args ) {
  94.       set $memcached_request 0;
  95.     }
  96.  
  97.     if ($http_cookie ~* "comment_author_|wordpressuser_|wp-postpass_|wordpress_logged_in_" ) {
  98.       set $memcached_request 0;
  99.     }
  100.  
  101.     location @fallback {
  102.       fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$;
  103.       fastcgi_param SCRIPT_FILENAME $document_root$script_name;
  104.       fastcgi_param PATH_TRANSLATED $document_root$path_info;
  105.       include params/fastcgi;
  106.       fastcgi_keep_conn on;
  107.       fastcgi_pass php-fpm;
  108.     }
  109.  
  110.     location ~ ^(?<script_name>.+?\.php)(?<path_info>.*)$ {
  111.       default_type text/html;
  112.       if ( $memcached_request = 1) {
  113.         memcached_pass memcached;
  114.         error_page 404 = @fallback;
  115.       }
  116.      
  117.       fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$;  
  118.       fastcgi_param SCRIPT_FILENAME $document_root$script_name;
  119.       fastcgi_param PATH_TRANSLATED $document_root$path_info;
  120.       include params/fastcgi;
  121.       fastcgi_keep_conn on;
  122.       fastcgi_pass php-fpm;
  123.     }
  124.  
  125.     location / {
  126.       try_files $uri $uri/ @rewrites;
  127.     }
  128.  
  129.     location @rewrites {
  130.       rewrite ^ /index.php last;
  131.     }
  132.   }
  133. }
  134.  
  135.  
  136.  
  137.  
  138. params/fastcgi:
  139. fastcgi_param  SCRIPT_NAME      $script_name;
  140. fastcgi_param  PATH_INFO      $path_info;
  141. fastcgi_param  QUERY_STRING    $query_string;
  142. fastcgi_param  REQUEST_METHOD    $request_method;
  143. fastcgi_param  CONTENT_TYPE    $content_type;
  144. fastcgi_param  CONTENT_LENGTH    $content_length;
  145. fastcgi_param  SCRIPT_NAME      $script_name;
  146. fastcgi_param  REQUEST_URI      $request_uri;
  147. fastcgi_param  DOCUMENT_URI    $document_uri;
  148. fastcgi_param  DOCUMENT_ROOT    $document_root;
  149. fastcgi_param  SERVER_PROTOCOL    $server_protocol;
  150. fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
  151. fastcgi_param  SERVER_SOFTWARE    nginx;
  152. fastcgi_param  REMOTE_ADDR      $remote_addr;
  153. fastcgi_param  REMOTE_PORT      $remote_port;
  154. fastcgi_param  SERVER_ADDR      $server_addr;
  155. fastcgi_param  SERVER_PORT      $server_port;
  156. fastcgi_param  SERVER_NAME      $server_name;
  157. fastcgi_param  HTTPS        $https if_not_empty;
  158. fastcgi_param  SSL_PROTOCOL    $ssl_protocol if_not_empty;
  159. fastcgi_param  SSL_CIPHER      $ssl_cipher if_not_empty;
  160. fastcgi_param  SSL_SESSION_ID    $ssl_session_id if_not_empty;
  161. fastcgi_param  SSL_CLIENT_VERIFY  $ssl_client_verify if_not_empty;
  162. fastcgi_param  REDIRECT_STATUS    200;
  163. fastcgi_index           index.php;
  164. fastcgi_connect_timeout      10;
  165. fastcgi_send_timeout      360;
  166. fastcgi_read_timeout      3600;
  167. fastcgi_buffer_size        512k;
  168. fastcgi_buffers          512 512k;
  169. fastcgi_intercept_errors    on;
  170. fastcgi_split_path_info ^(?<script_name>.+?\.php)(?<path_info>.*)$;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement