Advertisement
Guest User

qbit nginx example

a guest
May 1st, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.06 KB | None | 0 0
  1. user www;
  2. worker_processes 4;
  3. pid /var/run/nginx.pid;
  4.  
  5. events {
  6. worker_connections 1024;
  7. multi_accept on;
  8. }
  9.  
  10. http {
  11.  
  12. ##
  13. # Basic Settings
  14. ##
  15.  
  16. expires max;
  17.  
  18. sendfile on;
  19. tcp_nopush on;
  20. tcp_nodelay on;
  21. keepalive_timeout 65;
  22. types_hash_max_size 2048;
  23. server_tokens off;
  24.  
  25. # server_names_hash_bucket_size 64;
  26. # server_name_in_redirect off;
  27.  
  28. include /usr/local/etc/nginx/mime.types;
  29. default_type application/octet-stream;
  30.  
  31. set_real_ip_from 192.168.10.1; #Put the Ip of your varnish/proxy here
  32. real_ip_header X-Forwarded-For; #Put the Header that your varnish/proxy set
  33.  
  34. ##
  35. # Logging Settings
  36. ##
  37.  
  38. access_log /var/log/nginx-access.log;
  39. error_log /var/log/nginx-error.log;
  40.  
  41. ##
  42. # Gzip Settings
  43. ##
  44.  
  45. gzip on;
  46. gzip_disable "msie6";
  47. # gzip_min_length 1024;
  48. gzip_min_length 640;
  49. gzip_vary on;
  50. gzip_proxied any;
  51. gzip_comp_level 6;
  52. gzip_buffers 16 8k;
  53. gzip_http_version 1.1;
  54. gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
  55.  
  56.  
  57.  
  58. # Virtual Host Configs
  59.  
  60. server {
  61.  
  62. # listen 8080;
  63. listen 8080 default_server accept_filter=httpready;
  64. root /usr/local/www/nginx/;
  65. index index.php index.html index.htm;
  66. # index index.html index.htm;
  67. server_name testbed.test.zip;
  68.  
  69. fastcgi_intercept_errors on;
  70. error_page 500 502 503 504 400 403 404 /notfound.html;
  71.  
  72.  
  73. # Deny certain User-Agents (case insensitive)
  74. # The ~* makes it case insensitive as opposed to just a ~
  75.  
  76. if ($http_user_agent ~* (Baiduspider|ZmEu|Morfeus\ Fucking\ Scanner|xmlset_roodkcableoj28840ybtide|DataCha0s/2.0|masscan/1.0|Zollard|CrowdStrike\ ShellShock\ Scanner/1.0|x00_-gawa.sa.pilipinas.2015) ) {
  77. return 418;
  78. }
  79.  
  80.  
  81. location / {
  82. try_files $uri $uri/ /index.php;
  83.  
  84. if (!-e $request_filename){
  85. rewrite ^/(.*)$ /index.php?/$1? last;
  86. }
  87. }
  88.  
  89. # Below is Expression Engine section
  90.  
  91. location /index.php {
  92.  
  93. set $script $uri;
  94. set $path_info "";
  95.  
  96. if ($uri ~ "^(.+\.php)(/.+)") {
  97.  
  98. set $script $1;
  99. set $path_info $2;
  100. }
  101.  
  102. include fastcgi_params;
  103. fastcgi_index index.php;
  104. fastcgi_pass unix:/tmp/php-fm.sock;
  105. fastcgi_param SCRIPT_FILENAME /usr/local/www/nginx/index.php;
  106. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  107. fastcgi_param PATH_INFO $path_info;
  108. }
  109.  
  110.  
  111. # Below is for the Expression Engine Control Panel
  112.  
  113. location /system/ {
  114.  
  115. if (-f $request_filename) {
  116. expires max;
  117. break;
  118. }
  119.  
  120. if (!-e $request_filename) {
  121. rewrite ^/system/(.*)$ /system/index.php/$1 last;
  122. }
  123. }
  124.  
  125. location /system/index.php {
  126. fastcgi_pass unix:/tmp/php-fm.sock;
  127. fastcgi_index index.php;
  128. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  129. include fastcgi_params;
  130. }
  131.  
  132.  
  133.  
  134. # Below is a working Codeigniter section
  135.  
  136. location /cheatsheets/ {
  137.  
  138. if (-f $request_filename) {
  139. expires max;
  140. break;
  141. }
  142.  
  143. if (!-e $request_filename) {
  144. rewrite ^/cheatsheets/(.*)$ /cheatsheets/index.php/$1 last;
  145. }
  146. }
  147.  
  148. location = /notfound.html {
  149. root /usr/local/www/nginx;
  150. }
  151.  
  152. location /cheatsheets/index.php {
  153. fastcgi_pass unix:/tmp/php-fm.sock;
  154. fastcgi_index index.php;
  155. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  156. include fastcgi_params;
  157. }
  158.  
  159.  
  160. # This is to cover things like phpinfo.php in root
  161.  
  162. location ~ \.php$ {
  163. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  164. # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  165. include fastcgi_params;
  166. fastcgi_index index.php;
  167. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  168. fastcgi_pass unix:/tmp/php-fm.sock;
  169. }
  170.  
  171.  
  172. # Below ends server section near beginning
  173. }
  174. # Below ends http section at beginning
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement