server { server_name localhost; error_page 404 /404.html; root D:/xampp/htdocs/it; listen 80; # listen 80 deferred; # for Linux #listen 443 ssl spdy; #include nginx-bp/enable/ssl.conf; #ssl_certificate /etc/nginx/certs/server.crt; #ssl_certificate_key /etc/nginx/certs/server.key; # Allow uploads? client_max_body_size 200M; # Gzip compression? gzip on; gzip_http_version 1.0; gzip_min_length 1100; gzip_buffers 4 8k; gzip_types # text/html is always compressed by HttpGzipModule text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml; gzip_static on; gzip_proxied expired no-cache no-store private auth; gzip_disable "msie6"; gzip_vary on; gzip_comp_level 3; # Protect system files? location ~ (?:/\..*|~)$ { access_log off; log_not_found off; deny all; } location ~* (?:^|/)\. { deny all; } location ~* (?:\.(?:bak|config|sql|fla|psd|ini|log|sh|inc|swp|dist)|~)$ { deny all; } # Restricted access? #allow 127.0.0.1; #deny all; location @php { # PHP enabled? fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_split_path_info ^(.+?\.php)(/.*)$; if ($uri ~ ^(?.+\.php)?(?/.*)?$) {} #Pathinfo may be unavailable if try_files is used. set $path_info_final $path_info; if ($fastcgi_path_info != '') { set $path_info_final $fastcgi_path_info; } fastcgi_param PATH_INFO $path_info_final; # $fastcgi_script_name is no good, because requests like /image/test/ # are resolved to /image/test/index.php set $script_name_final '/index.php'; if ($script_name != '') { set $script_name_final $script_name; } fastcgi_param SCRIPT_FILENAME $document_root$script_name_final; # If the actual target php script doesn't exist if (!-e $document_root$script_name_final) { return 404; } # override SCRIPT_NAME which is set to $fastcgi_script_name fastcgi_param SCRIPT_NAME $script_name_final; # Pathinfo is used, make it more obvious to scripts set $request_uri_final $request_uri; if ($path_info_final != '') { set $request_uri_final $path_info_final$is_args$args; } fastcgi_param REQUEST_URI $request_uri_final; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param QUERY_STRING $query_string; fastcgi_index index.php; fastcgi_next_upstream error timeout; fastcgi_keep_conn on; fastcgi_hide_header "X-Powered-By"; # Use this instead if Php is off #return 405; #Php caching #include nginx-bp/enable/php_cache.conf; #fastcgi_cache_valid 200 301 302 304 1h; #fastcgi_cache_min_uses 3; #Php request limiting? #limit_req zone=reqPerSec10 burst=50 nodelay; #limit_conn conPerIp 25; #rewrite ^/(.*)$ /index.php?$1 last; #break; #try_files !noop! /index.php?$args; } location ~ ^.*\.php(?:/.*)?$ { try_files !noop! @php; } # Use custom error pages? fastcgi_intercept_errors on; location ~ [4-5][0-9][0-9].html { internal; access_log off; log_not_found off; } error_page 404 /404.html; # tweaks client_body_buffer_size 10K; client_header_buffer_size 1k; large_client_header_buffers 2 1k; # tweaks for higher traffic #open_file_cache max=1000 inactive=20s; #open_file_cache_valid 30s; #open_file_cache_min_uses 2; #open_file_cache_errors on; # Allowed methods if ($request_method !~ ^(OPTIONS|GET|HEAD|POST|PUT|PATCH|DELETE)$ ) { return 405; } if ($bot_ua = 1) { set $is_bot 1; set $is_human 0; } if ($bot_ua = 0) { set $is_bot 0; set $is_human 1; } # Log bots? # "if=" is available for Nginx >= 1.7 #access_log /var/log/nginx/localhost.bots.log main flush=5m buffer=32k if=$is_bot; #access_log off; # Log humans? # "if=" is available for Nginx >= 1.7 access_log /nginx/logs/localhost.access.log; # Error logging error_log /nginx/logs/localhost.error.log error; log_not_found on; # Static requests limiting #limit_req zone=reqPerSec20 burst=100 nodelay; #limit_conn conPerIp 20; # Seconds to wait for backend to generate a page fastcgi_read_timeout 15; # Default location / location / { #try_files $uri $uri/ /index.php?/$args; try_files $uri $uri/ @php; # rewrite www.example.com → example.com if ($host ~* ^www\.(.*)$) { set $host_without_www $1; rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent; } if ($fastcgi_script_name ~ "-d") { return 403; } if ($fastcgi_script_name ~ "-f") { return 403; } # removes trailing "index" from all controllers if ($request_uri ~* index/?$) { rewrite ^/(.*)/index/?$ /$1 permanent; } if (!-e $request_filename) { rewrite ^(.+)$ /index.php?$1 last; #break; } # removes trailing slashes (prevents SEO duplicate content issues) if (!-d $request_filename) { rewrite ^/(.*)/$ /$1 permanent; rewrite ^(.*)$ /index.php?/$1 last; break; } } # Handle static files # H5BP Directives include nginx-bp/h5bp/location/expires.conf; include nginx-bp/h5bp/location/cross-domain-fonts.conf; include nginx-bp/h5bp/location/cache-busting.conf; include nginx-bp/h5bp/directive-only/cross-domain-insecure.conf; include nginx-bp/h5bp/directive-only/no-transform.conf; #include nginx-bp/h5bp/directive-only/spdy.conf; ssl needed. :-/ include nginx-bp/h5bp/directive-only/x-ua-compatible.conf; autoindex off; location ~ \.php$ { try_files $uri =404; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }