Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.13 KB | None | 0 0
  1.  
  2. #user  nobody;
  3. worker_processes  4;
  4.  
  5. #error_log  logs/error.log;
  6. #error_log  logs/error.log  notice;
  7. #error_log  logs/error.log  info;
  8.  
  9. error_log  logs/error.log  warn;
  10.  
  11. #error_log  logs/error.log  debug;
  12. pid        logs/nginx.pid;
  13.  
  14.  
  15. events {
  16.     worker_connections  1024;
  17. }
  18.  
  19.  
  20. http {
  21.     include       mime.types;
  22.     #default_type  application/octet-stream;
  23.     client_max_body_size 150M;
  24.     client_body_buffer_size 16K;
  25.     client_header_buffer_size 1k;
  26.     large_client_header_buffers 4 8k;
  27.  
  28.     ## increase the timelimit for execution
  29.     fastcgi_read_timeout 300;
  30.  
  31.  
  32.     #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  33.     #                  '$status $body_bytes_sent "$http_referer" '
  34.     #                  '"$http_user_agent" "$http_x_forwarded_for"';
  35.  
  36.     #access_log  logs/access.log  main;
  37.  
  38.     sendfile        on;
  39.     tcp_nopush     on;
  40.  
  41.     #keepalive_timeout  0;
  42.     keepalive_timeout  5;
  43.     client_body_timeout 12;
  44.     client_header_timeout 12;
  45.     send_timeout 10;
  46.  
  47.     gzip             on;
  48.     gzip_comp_level  2;
  49.     gzip_min_length  1000;
  50.     gzip_types       text/plain application/x-javascript text/xml text/css application/xml;
  51.  
  52.     ## include the cahce thing
  53.     ## https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps
  54.     fastcgi_cache_path C:/nginx/cache levels=1:2 keys_zone=MYAPP:20m inactive=2m max_size=500m;
  55.     #fastcgi_cache_path R:/cache levels=1:2 keys_zone=MYAPP:20m inactive=30m max_size=500m;
  56.  
  57.     fastcgi_cache_key "$scheme$request_method$host$request_uri";
  58.  
  59.     add_header X-Cache $upstream_cache_status;
  60.  
  61.  
  62.     ##configure settings below to not strenghten the server and expose less
  63.     server_tokens off; ## remove nginx version
  64.     #proxy_hide_header X-Powered-By; ## remove php version for proxy
  65.     # toremove php version edit php.ini expose_php = Off
  66.     add_header X-Frame-Options SAMEORIGIN; ## add extra header for more security?
  67.  
  68.     ## disable rendering stuff inside iframe element
  69.     add_header X-XSS-Protection "1; mode=block";
  70.  
  71.     ## to disable content-type sniffing on some browsers.
  72.     add_header X-Content-Type-Options nosniff;
  73.  
  74.     ## set the limit buffer size or something.
  75.     limit_conn_zone $binary_remote_addr zone=perip:10m;
  76.  
  77.     ## This should ignore cache paramenters altogehter and cache it anyway...
  78.     # Makes cache for every user and works for logged in users as well. YAAY?
  79.     fastcgi_ignore_headers Cache-Control Expires Set-Cookie; # this works ok my channel 1st 17 sec-> cache-> 0,7 sec
  80.  
  81.     server{
  82.             listen  80;
  83.             #listen       80;
  84.  
  85.             server_name www.domain.dev
  86.                         domain.dev
  87.                         "";
  88.  
  89.             root C:/nginx/public_html/domain.dev/;
  90.  
  91.             ##-------------------------------------------------------##
  92.             # Limits connections per IP, comment for AB testing.
  93.             ##-------------------------------------------------------##
  94.             #limit_conn perip 10;
  95.  
  96.             ##-------------------------------------------------------##
  97.             # HTTP-> HTTPS TLS SSL
  98.             # get windows executable here https://commaster.net/content/how-setup-lets-encrypt-apache-windows
  99.             # and nginx settings here https://www.bjornjohansen.no/letsencrypt-nginx
  100.             # will not work on red one so try on laptop instead.
  101.             # https://wtserver.wtriple.com/howtoLetsEncrypt.php   <- should work on win
  102.             ##-------------------------------------------------------##
  103.  
  104.             ##-------------------------------------------------------##
  105.             # Microcaching on nginx
  106.             # i dont know what kind of caching i have set up here.
  107.             # https://www.howtoforge.com/why-you-should-always-use-nginx-with-microcaching
  108.             # try it ;D
  109.             ##-------------------------------------------------------##
  110.  
  111.             #--------------------------------------#
  112.             # /CDN/...  configuration here
  113.             # allow only images of png/jpeg/pjg
  114.             #--------------------------------------#
  115.  
  116.             # location /CDN {
  117.             #     alias C:/xampp/htdocs/content;
  118.             #     #alias C:/xampp/htdocs/content/two-vod/thumbn/;
  119.             #     autoindex on;
  120.             #     #try_files $uri $uri/ =404;
  121.             # }  
  122.  
  123.             location ^~ /CDN/ {
  124.                 #alias C:/xampp/htdocs/content/;
  125.                 alias C:/xampp/htdocs/content/two-vod/thumbn/;
  126.                 #autoindex on;
  127.                 #try_files $uri $uri/ =404;
  128.             }  
  129.                    
  130.  
  131.             ## some more caching settings XCV
  132.             #Cache everything by default
  133.             set $no_cache 0;
  134.  
  135.             ## uncomment to disable caching( will not delete cached responses)
  136.             #set $no_cache 1;
  137.  
  138.             #Don't cache POST requests
  139.             if ($request_method = POST)
  140.             {
  141.                 set $no_cache 1;
  142.             }
  143.  
  144.             #Don't cache if the URL contains a query string
  145.             # if ($query_string != "")
  146.             # {
  147.             #     set $no_cache 1;
  148.             # }
  149.  
  150.             #Don't cache the following URLs
  151.             #if ($request_uri ~* "/(wp-admin/|cron_cron/|my-account/)")
  152.             if ($request_uri ~* "/(wp-admin/|cron_cron/|cart/|checkout/)")
  153.             {
  154.                 set $no_cache 1;
  155.             }
  156.  
  157.             #Don't cache if there is a cookie called PHPSESSID
  158.             # some plugins might use this cookie or who knows what sets it .
  159.             # if ($http_cookie = "PHPSESSID")
  160.             # {
  161.             #     set $no_cache 1;
  162.             #     #set $no_cache 0;
  163.             # }
  164.  
  165.             ## Set expiration time for browser cache files below
  166.             ## https://www.howtoforge.com/make-browsers-cache-static-files-on-nginx
  167.             location ~*  \.(jpg|jpeg|png|gif|ico|css|js)$ {
  168.             expires 7d;
  169.             }
  170.  
  171.             location / {
  172.                 index  index.php index.html;
  173.                 ## this should be working with permalinks
  174.                 try_files $uri $uri/ /index.php?$args; ## This just started to magicaly work lol wo wtf :D?
  175.             }
  176.  
  177.           ## Disabling php direct php execution  in the following folders
  178.           ## https://www.bjornjohansen.no/block-access-to-php-files-with-nginx
  179.             location ~* /(?:uploads|files)/.*.php$ {
  180.                 deny all;
  181.                 access_log off;
  182.                 log_not_found off;
  183.             }
  184.             location ~* /wp-includes/.*.php$ {
  185.                 deny all;
  186.                 access_log off;
  187.                 log_not_found off;
  188.             }
  189.             location ~* /wp-content/.*.php$ {
  190.                 deny all;
  191.                 access_log off;
  192.                 log_not_found off;
  193.             }
  194.             location = /xmlrpc.php {
  195.                 deny all;
  196.                 access_log off;
  197.                 log_not_found off;
  198.             }
  199.             #deny access to these files.
  200.             location ~ /(wp-config.php|wp-comments-post.php|readme.html|license.txt) {
  201.                 deny all;
  202.             }
  203.  
  204.  
  205.  
  206.             ## enable the cache for php files
  207.             location ~ \.php$ {
  208.             ##fastcgi_pass   127.0.0.1:9000;
  209.             fastcgi_pass   127.0.0.1:9011;
  210.             fastcgi_index  index.php;
  211.             fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  212.             include        fastcgi_params;
  213.  
  214.             ## probably to disable 0 day attacks
  215.             ## https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/
  216.             fastcgi_split_path_info ^(.+\.php)(/.+)$;
  217.  
  218.             ## some kind of wordpress cookie cache thing
  219.             set $cs_session "";
  220.             if ($http_cookie ~* "wordpress_logged_in_[^=]*=([^%]+)%7C") {
  221.                     set $cs_session wordpress_logged_in_$1;
  222.             }
  223.             fastcgi_cache_key "$scheme$request_method$host$request_uri$cs_session";
  224.  
  225.             ## cache settings start
  226.             fastcgi_cache MYAPP;
  227.          
  228.             ##how long the cache is valid
  229.             fastcgi_cache_valid 200 301 302 1m;
  230.  
  231.             ## allow updating response while serving old content
  232.             fastcgi_cache_use_stale updating;
  233.  
  234.             ## additional config related to some more caching settings XCV
  235.             fastcgi_cache_bypass $no_cache;
  236.             fastcgi_no_cache $no_cache;
  237.  
  238.             ## allows only first request to be generated rest will get old cache
  239.             ## https://www.nginx.com/blog/nginx-caching-guide/
  240.              proxy_cache_lock on;
  241.  
  242.             ##hide the cookie when serving from cache
  243.             #  CAN NOT LOG IN IF THIS IS ENABLED
  244.             #fastcgi_hide_header "Set-Cookie";
  245.  
  246.  
  247.  
  248.             ##this will show 404 page for non exisitng php documents works only if php and nxgin are on same server
  249.             try_files  $uri =404;
  250.          }
  251.          ## specific access log with buffer size 5 mb and flush time 5 min
  252.          access_log logs/access_log_karamba.log combined flush=5m buffer=5m;
  253.     }
  254.  
  255.  
  256.  
  257.  
  258.  
  259.     #--------------------------------------#
  260.     # phpmyadmin on different port here
  261.     #--------------------------------------#
  262.  
  263.     server{
  264.  
  265.         listen 127.0.0.1:8066; ## only from locahost available Yet this sets it as default server for some reason unless port specified other than :80
  266.          #listen 127.0.0.1;
  267.           server_name www.domain.dev domain.dev;
  268.           root C:/nginx/public_html/phpMyAdmin/;
  269.  
  270.           location / {
  271.             index  index.php index.html;
  272.           }
  273.  
  274.            location ~ \.php$ {
  275.            fastcgi_pass   127.0.0.1:9011;
  276.            fastcgi_index  index.php;
  277.            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  278.            #fastcgi_param  SCRIPT_FILENAME  C:/nginx/public_html/localhost$fastcgi_script_name;
  279.            include        fastcgi_params;
  280.            #include fastcgi.conf;
  281.  
  282.            ##this will show 404 page for non exisitng php documents
  283.            try_files  $uri =404;
  284.            }
  285.     }
  286.  
  287.  
  288.  
  289.  
  290. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement