0. Install nginx package

Linux has main 2 web server, apache and nginx. Here we will install and run nginx, fast and light reverse-proxy web server.

$ sudo apt install nginx -y

1. Check nginx is running

Open your web browser and move to ip address of Raspberry Pi.

If you see “Welcome to nginx on debia!” page, installation is successful.

2. nginx host configuration file

Default nginx configuration file is /etc/nginx/nginx.conf

Here is example of nginx.conf file

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
	worker_connections 1024;
	# multi_accept on;
}

http {
	 SSL ENHANCE

	add_header X-Frame-Options		SAMEORIGIN;
	add_header X-Content-Type-Options	nosniff;
	add_header X-XSS-Protection		"1; mode=block";


	
	# Basic Settings
	

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 4096;
	# 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;

	
	# Logging Settings
	

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

	
	# Gzip Settings
	

	gzip on;
	gzip_disable "msie6";

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

	
	# 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;
#	}
#}

Open nginx.conf then change worker_processes 4; as your CPU processor number.

e.g) Raspberry Pi 1 Model B or B+ you can put worker_process 1;

You can see include /etc/nginx/sites-enabled/*;

In /etc/nginx/sites-enabled/ folder, you can see default file, this is symlink of /etc/nginx/sites-available/default

So, /etc/nginx/sites-available/default file should be the virtual-server configuration file.

We will go final configuration of nginx after complete install mariadb and php7.0.