Advertisement
pushrbx

Untitled

Aug 10th, 2014
289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.22 KB | None | 0 0
  1. server
  2. {
  3. server_name localhost;
  4. error_page 404 /404.html;
  5.  
  6. root D:/xampp/htdocs/it;
  7. listen 80;
  8. # listen 80 deferred; # for Linux
  9.  
  10. #listen 443 ssl spdy;
  11. #include nginx-bp/enable/ssl.conf;
  12. #ssl_certificate /etc/nginx/certs/server.crt;
  13. #ssl_certificate_key /etc/nginx/certs/server.key;
  14.  
  15. # Allow uploads?
  16. client_max_body_size 200M;
  17.  
  18. # Gzip compression?
  19. gzip on;
  20. gzip_http_version 1.0;
  21. gzip_min_length 1100;
  22. gzip_buffers 4 8k;
  23. gzip_types
  24. # text/html is always compressed by HttpGzipModule
  25. text/css
  26. text/javascript
  27. text/xml
  28. text/plain
  29. text/x-component
  30. application/javascript
  31. application/x-javascript
  32. application/json
  33. application/xml
  34. application/rss+xml
  35. application/atom+xml
  36. font/truetype
  37. font/opentype
  38. application/vnd.ms-fontobject
  39. image/svg+xml;
  40. gzip_static on;
  41. gzip_proxied expired no-cache no-store private auth;
  42. gzip_disable "msie6";
  43. gzip_vary on;
  44. gzip_comp_level 3;
  45.  
  46. # Protect system files?
  47. location ~ (?:/\..*|~)$
  48. {
  49. access_log off;
  50. log_not_found off;
  51. deny all;
  52. }
  53.  
  54. location ~* (?:^|/)\. {
  55. deny all;
  56. }
  57.  
  58. location ~* (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ {
  59. deny all;
  60. }
  61. # Restricted access?
  62. #allow 127.0.0.1;
  63. #deny all;
  64.  
  65. location @php
  66. {
  67. # PHP enabled?
  68. fastcgi_pass 127.0.0.1:9000;
  69.  
  70. include fastcgi_params;
  71.  
  72. fastcgi_split_path_info ^(.+?\.php)(/.*)$;
  73. if ($uri ~ ^(?<script_name>.+\.php)?(?<path_info>/.*)?$) {}
  74.  
  75. #Pathinfo may be unavailable if try_files is used.
  76. set $path_info_final $path_info;
  77. if ($fastcgi_path_info != '')
  78. {
  79. set $path_info_final $fastcgi_path_info;
  80. }
  81. fastcgi_param PATH_INFO $path_info_final;
  82.  
  83. # $fastcgi_script_name is no good, because requests like /image/test/
  84. # are resolved to /image/test/index.php
  85. set $script_name_final '/index.php';
  86. if ($script_name != '')
  87. {
  88. set $script_name_final $script_name;
  89. }
  90. fastcgi_param SCRIPT_FILENAME $document_root$script_name_final;
  91.  
  92. # If the actual target php script doesn't exist
  93. if (!-e $document_root$script_name_final) {
  94. return 404;
  95. }
  96.  
  97. # override SCRIPT_NAME which is set to $fastcgi_script_name
  98. fastcgi_param SCRIPT_NAME $script_name_final;
  99.  
  100. # Pathinfo is used, make it more obvious to scripts
  101. set $request_uri_final $request_uri;
  102. if ($path_info_final != '') {
  103. set $request_uri_final $path_info_final$is_args$args;
  104. }
  105. fastcgi_param REQUEST_URI $request_uri_final;
  106. fastcgi_param CONTENT_TYPE $content_type;
  107. fastcgi_param CONTENT_LENGTH $content_length;
  108. fastcgi_param QUERY_STRING $query_string;
  109.  
  110. fastcgi_index index.php;
  111.  
  112. fastcgi_next_upstream error timeout;
  113. fastcgi_keep_conn on;
  114.  
  115. fastcgi_hide_header "X-Powered-By";
  116.  
  117.  
  118. # Use this instead if Php is off
  119. #return 405;
  120.  
  121. #Php caching
  122. #include nginx-bp/enable/php_cache.conf;
  123. #fastcgi_cache_valid 200 301 302 304 1h;
  124. #fastcgi_cache_min_uses 3;
  125.  
  126. #Php request limiting?
  127. #limit_req zone=reqPerSec10 burst=50 nodelay;
  128. #limit_conn conPerIp 25;
  129.  
  130. #rewrite ^/(.*)$ /index.php?$1 last;
  131. #break;
  132. #try_files !noop! /index.php?$args;
  133. }
  134.  
  135. location ~ ^.*\.php(?:/.*)?$
  136. {
  137. try_files !noop! @php;
  138. }
  139.  
  140. # Use custom error pages?
  141. fastcgi_intercept_errors on;
  142. location ~ [4-5][0-9][0-9].html
  143. {
  144. internal;
  145. access_log off;
  146. log_not_found off;
  147. }
  148. error_page 404 /404.html;
  149.  
  150. # tweaks
  151. client_body_buffer_size 10K;
  152. client_header_buffer_size 1k;
  153. large_client_header_buffers 2 1k;
  154.  
  155. # tweaks for higher traffic
  156. #open_file_cache max=1000 inactive=20s;
  157. #open_file_cache_valid 30s;
  158. #open_file_cache_min_uses 2;
  159. #open_file_cache_errors on;
  160.  
  161.  
  162. # Allowed methods
  163. if ($request_method !~ ^(OPTIONS|GET|HEAD|POST|PUT|PATCH|DELETE)$ ) {
  164. return 405;
  165. }
  166.  
  167. if ($bot_ua = 1) {
  168. set $is_bot 1;
  169. set $is_human 0;
  170. }
  171.  
  172. if ($bot_ua = 0) {
  173. set $is_bot 0;
  174. set $is_human 1;
  175. }
  176.  
  177. # Log bots?
  178. # "if=" is available for Nginx >= 1.7
  179. #access_log /var/log/nginx/localhost.bots.log main flush=5m buffer=32k if=$is_bot;
  180. #access_log off;
  181.  
  182. # Log humans?
  183. # "if=" is available for Nginx >= 1.7
  184. access_log /nginx/logs/localhost.access.log;
  185.  
  186. # Error logging
  187. error_log /nginx/logs/localhost.error.log error;
  188. log_not_found on;
  189.  
  190. # Static requests limiting
  191. #limit_req zone=reqPerSec20 burst=100 nodelay;
  192. #limit_conn conPerIp 20;
  193.  
  194. # Seconds to wait for backend to generate a page
  195. fastcgi_read_timeout 15;
  196.  
  197. # Default location /
  198. location /
  199. {
  200. #try_files $uri $uri/ /index.php?/$args;
  201. try_files $uri $uri/ @php;
  202. # rewrite www.example.com → example.com
  203. if ($host ~* ^www\.(.*)$) {
  204. set $host_without_www $1;
  205. rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
  206. }
  207. if ($fastcgi_script_name ~ "-d") {
  208. return 403;
  209. }
  210. if ($fastcgi_script_name ~ "-f") {
  211. return 403;
  212. }
  213.  
  214. # removes trailing "index" from all controllers
  215. if ($request_uri ~* index/?$)
  216. {
  217. rewrite ^/(.*)/index/?$ /$1 permanent;
  218. }
  219.  
  220. if (!-e $request_filename)
  221. {
  222. rewrite ^(.+)$ /index.php?$1 last;
  223. #break;
  224. }
  225.  
  226. # removes trailing slashes (prevents SEO duplicate content issues)
  227. if (!-d $request_filename)
  228. {
  229. rewrite ^/(.*)/$ /$1 permanent;
  230. rewrite ^(.*)$ /index.php?/$1 last;
  231. break;
  232. }
  233. }
  234.  
  235. # Handle static files
  236. # H5BP Directives
  237. include nginx-bp/h5bp/location/expires.conf;
  238. include nginx-bp/h5bp/location/cross-domain-fonts.conf;
  239. include nginx-bp/h5bp/location/cache-busting.conf;
  240. include nginx-bp/h5bp/directive-only/cross-domain-insecure.conf;
  241. include nginx-bp/h5bp/directive-only/no-transform.conf;
  242. #include nginx-bp/h5bp/directive-only/spdy.conf; ssl needed. :-/
  243. include nginx-bp/h5bp/directive-only/x-ua-compatible.conf;
  244.  
  245.  
  246. autoindex off;
  247.  
  248. location ~ \.php$
  249. {
  250. try_files $uri =404;
  251. include fastcgi_params;
  252. fastcgi_pass 127.0.0.1:9000;
  253. fastcgi_index index.php;
  254. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  255. }
  256. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement