Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #user nobody;
- worker_processes 4;
- #error_log logs/error.log;
- #error_log logs/error.log notice;
- #error_log logs/error.log info;
- error_log logs/error.log warn;
- #error_log logs/error.log debug;
- pid logs/nginx.pid;
- events {
- worker_connections 1024;
- }
- http {
- include mime.types;
- #default_type application/octet-stream;
- client_max_body_size 150M;
- client_body_buffer_size 16K;
- client_header_buffer_size 1k;
- large_client_header_buffers 4 8k;
- ## increase the timelimit for execution
- fastcgi_read_timeout 300;
- #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
- # '$status $body_bytes_sent "$http_referer" '
- # '"$http_user_agent" "$http_x_forwarded_for"';
- #access_log logs/access.log main;
- sendfile on;
- tcp_nopush on;
- #keepalive_timeout 0;
- keepalive_timeout 5;
- client_body_timeout 12;
- client_header_timeout 12;
- send_timeout 10;
- gzip on;
- gzip_comp_level 2;
- gzip_min_length 1000;
- gzip_types text/plain application/x-javascript text/xml text/css application/xml;
- ## include the cahce thing
- ## https://www.digitalocean.com/community/tutorials/how-to-setup-fastcgi-caching-with-nginx-on-your-vps
- fastcgi_cache_path C:/nginx/cache levels=1:2 keys_zone=MYAPP:20m inactive=2m max_size=500m;
- #fastcgi_cache_path R:/cache levels=1:2 keys_zone=MYAPP:20m inactive=30m max_size=500m;
- fastcgi_cache_key "$scheme$request_method$host$request_uri";
- add_header X-Cache $upstream_cache_status;
- ##configure settings below to not strenghten the server and expose less
- server_tokens off; ## remove nginx version
- #proxy_hide_header X-Powered-By; ## remove php version for proxy
- # toremove php version edit php.ini expose_php = Off
- add_header X-Frame-Options SAMEORIGIN; ## add extra header for more security?
- ## disable rendering stuff inside iframe element
- add_header X-XSS-Protection "1; mode=block";
- ## to disable content-type sniffing on some browsers.
- add_header X-Content-Type-Options nosniff;
- ## set the limit buffer size or something.
- limit_conn_zone $binary_remote_addr zone=perip:10m;
- ## This should ignore cache paramenters altogehter and cache it anyway...
- # Makes cache for every user and works for logged in users as well. YAAY?
- fastcgi_ignore_headers Cache-Control Expires Set-Cookie; # this works ok my channel 1st 17 sec-> cache-> 0,7 sec
- server{
- listen 80;
- #listen 80;
- server_name www.domain.dev
- domain.dev
- "";
- root C:/nginx/public_html/domain.dev/;
- ##-------------------------------------------------------##
- # Limits connections per IP, comment for AB testing.
- ##-------------------------------------------------------##
- #limit_conn perip 10;
- ##-------------------------------------------------------##
- # HTTP-> HTTPS TLS SSL
- # get windows executable here https://commaster.net/content/how-setup-lets-encrypt-apache-windows
- # and nginx settings here https://www.bjornjohansen.no/letsencrypt-nginx
- # will not work on red one so try on laptop instead.
- # https://wtserver.wtriple.com/howtoLetsEncrypt.php <- should work on win
- ##-------------------------------------------------------##
- ##-------------------------------------------------------##
- # Microcaching on nginx
- # i dont know what kind of caching i have set up here.
- # https://www.howtoforge.com/why-you-should-always-use-nginx-with-microcaching
- # try it ;D
- ##-------------------------------------------------------##
- #--------------------------------------#
- # /CDN/... configuration here
- # allow only images of png/jpeg/pjg
- #--------------------------------------#
- # location /CDN {
- # alias C:/xampp/htdocs/content;
- # #alias C:/xampp/htdocs/content/two-vod/thumbn/;
- # autoindex on;
- # #try_files $uri $uri/ =404;
- # }
- location ^~ /CDN/ {
- #alias C:/xampp/htdocs/content/;
- alias C:/xampp/htdocs/content/two-vod/thumbn/;
- #autoindex on;
- #try_files $uri $uri/ =404;
- }
- ## some more caching settings XCV
- #Cache everything by default
- set $no_cache 0;
- ## uncomment to disable caching( will not delete cached responses)
- #set $no_cache 1;
- #Don't cache POST requests
- if ($request_method = POST)
- {
- set $no_cache 1;
- }
- #Don't cache if the URL contains a query string
- # if ($query_string != "")
- # {
- # set $no_cache 1;
- # }
- #Don't cache the following URLs
- #if ($request_uri ~* "/(wp-admin/|cron_cron/|my-account/)")
- if ($request_uri ~* "/(wp-admin/|cron_cron/|cart/|checkout/)")
- {
- set $no_cache 1;
- }
- #Don't cache if there is a cookie called PHPSESSID
- # some plugins might use this cookie or who knows what sets it .
- # if ($http_cookie = "PHPSESSID")
- # {
- # set $no_cache 1;
- # #set $no_cache 0;
- # }
- ## Set expiration time for browser cache files below
- ## https://www.howtoforge.com/make-browsers-cache-static-files-on-nginx
- location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
- expires 7d;
- }
- location / {
- index index.php index.html;
- ## this should be working with permalinks
- try_files $uri $uri/ /index.php?$args; ## This just started to magicaly work lol wo wtf :D?
- }
- ## Disabling php direct php execution in the following folders
- ## https://www.bjornjohansen.no/block-access-to-php-files-with-nginx
- location ~* /(?:uploads|files)/.*.php$ {
- deny all;
- access_log off;
- log_not_found off;
- }
- location ~* /wp-includes/.*.php$ {
- deny all;
- access_log off;
- log_not_found off;
- }
- location ~* /wp-content/.*.php$ {
- deny all;
- access_log off;
- log_not_found off;
- }
- location = /xmlrpc.php {
- deny all;
- access_log off;
- log_not_found off;
- }
- #deny access to these files.
- location ~ /(wp-config.php|wp-comments-post.php|readme.html|license.txt) {
- deny all;
- }
- ## enable the cache for php files
- location ~ \.php$ {
- ##fastcgi_pass 127.0.0.1:9000;
- fastcgi_pass 127.0.0.1:9011;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- include fastcgi_params;
- ## probably to disable 0 day attacks
- ## https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- ## some kind of wordpress cookie cache thing
- set $cs_session "";
- if ($http_cookie ~* "wordpress_logged_in_[^=]*=([^%]+)%7C") {
- set $cs_session wordpress_logged_in_$1;
- }
- fastcgi_cache_key "$scheme$request_method$host$request_uri$cs_session";
- ## cache settings start
- fastcgi_cache MYAPP;
- ##how long the cache is valid
- fastcgi_cache_valid 200 301 302 1m;
- ## allow updating response while serving old content
- fastcgi_cache_use_stale updating;
- ## additional config related to some more caching settings XCV
- fastcgi_cache_bypass $no_cache;
- fastcgi_no_cache $no_cache;
- ## allows only first request to be generated rest will get old cache
- ## https://www.nginx.com/blog/nginx-caching-guide/
- proxy_cache_lock on;
- ##hide the cookie when serving from cache
- # CAN NOT LOG IN IF THIS IS ENABLED
- #fastcgi_hide_header "Set-Cookie";
- ##this will show 404 page for non exisitng php documents works only if php and nxgin are on same server
- try_files $uri =404;
- }
- ## specific access log with buffer size 5 mb and flush time 5 min
- access_log logs/access_log_karamba.log combined flush=5m buffer=5m;
- }
- #--------------------------------------#
- # phpmyadmin on different port here
- #--------------------------------------#
- server{
- 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
- #listen 127.0.0.1;
- server_name www.domain.dev domain.dev;
- root C:/nginx/public_html/phpMyAdmin/;
- location / {
- index index.php index.html;
- }
- location ~ \.php$ {
- fastcgi_pass 127.0.0.1:9011;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- #fastcgi_param SCRIPT_FILENAME C:/nginx/public_html/localhost$fastcgi_script_name;
- include fastcgi_params;
- #include fastcgi.conf;
- ##this will show 404 page for non exisitng php documents
- try_files $uri =404;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement