Configure Nginx

Written by

in

, ,

Make directories

$ sudo mkdir /etc/nginx/global
$ sudo mkdir /etc/nginx/sites-available
$ sudo mkdir /etc/nginx/sites-enable

Configure Nginx

Edit /etc/nginx/nginx.conf

$ sudo vi /etc/nginx/nginx.conf
# Generic startup file.
user http;
 
#usually equal to number of CPUs you have. run command "grep processor /proc/cpuinfo | wc -l" to find it
worker_processes  auto;
worker_cpu_affinity auto;
 
error_log  /var/log/nginx/error.log;
#pid        /run/nginx.pid;
 
# Keeps the logs free of messages about not being able to bind().
#daemon     off;
 
events {
    worker_connections  1024;
}
 
http {
#   rewrite_log on;
 
    include mime.types;
    default_type       application/octet-stream;
    access_log         /var/log/nginx/access.log;
    sendfile           on;
#   tcp_nopush         on;
    keepalive_timeout  3;
#   tcp_nodelay        on;
    gzip               on;
    #php max upload limit cannot be larger than this       
    client_max_body_size 5G;
    index              index.php index.html index.htm;
 
    # Upstream to abstract backend connection(s) for PHP.
    upstream php {
       #this should match value of "listen" directive in php-fpm pool
       server unix:/run/php-fpm/php-fpm.sock;
       #server 127.0.0.1:9000;
    }
 
    include sites-enabled/*;
}

Edit restriction.conf

$ sudo vi /etc/nginx/global/restriction.conf
# Global restrictions configuration file.
# Designed to be included in any server {} block.</p>
location = /favicon.ico {
	log_not_found off;
	access_log off;
}

location = /robots.txt {
	allow all;
	log_not_found off;
	access_log off;
}

# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
# If this option is enabled, nextcloud can only upload up to 20MiB.
#location ~ /\. {
#	deny all;
#	access_log off;
#	log_not_found off;
#}

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *