user www-data;
worker_processes 2;
worker_rlimit_nofile 10240;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 4048;
	multi_accept        on;
    	use                 epoll;
}


http {

	##
	# Basic Settings
	##
	access_log off;

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 90;
	types_hash_max_size 2048;
	server_tokens off;


	server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# SSL Settings
	##
	

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;


	ssl_session_cache shared:SSL:50m;
   	ssl_session_timeout 1d;
   	ssl_session_tickets on;
   	ssl_stapling on;
	ssl_stapling_verify on;
   	resolver 8.8.8.8 8.8.4.4 208.67.222.222 208.67.220.220 valid=60s;
   	resolver_timeout 2s;


   	add_header X-Frame-Options "SAMEORIGIN" always;
   	add_header X-XSS-Protection "1; mode=block" always;
   	add_header X-Content-Type-Options "nosniff" always;
   	add_header Referrer-Policy "no-referrer-when-downgrade" always;
   	add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;

   	add_header Content-Security-Policy "default-src 'self' https://*; connect-src 'self' https://* wss://*; font-src 'self' https://* blob: data:; frame-src 'self' https://* blob: data:; img-src 'self' https://* blob: data:; media-src 'self' https://* blob: data:; object-src 'self' https://* blob: data:; script-src 'self' https://* 'unsafe-inline' 'unsafe-eval'; style-src 'self' https://* 'unsafe-inline';";


	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##
	client_body_timeout 32;
	client_header_timeout 32;
	reset_timedout_connection on;
	open_file_cache max=200000 inactive=20s;
	open_file_cache_valid 30s;
	open_file_cache_min_uses 2;
    	open_file_cache_errors on;

	send_timeout 120;
	gzip on;
    	gzip_disable "msie6";
    	gzip_vary on;
    	gzip_proxied expired no-cache no-store private auth;
    	gzip_comp_level 9;
    	gzip_buffers 32 16k;
    	gzip_http_version 1.1;
    	gzip_min_length 250;
    	gzip_types image/jpeg image/bmp image/svg+xml text/plain text/html text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon;
	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
# 
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}
