nginx default config file is fully commented with explanations
This commit is contained in:
@@ -4,8 +4,14 @@ RUN apt update && apt install -y nginx
|
||||
|
||||
COPY ./conf/nginx.conf /etc/nginx/
|
||||
COPY ./conf/inception_nginx.conf /etc/nginx/conf.d/
|
||||
|
||||
# for test
|
||||
COPY ./conf/index.html /data/www/
|
||||
COPY ./conf/salade.jpeg /data/images/
|
||||
|
||||
CMD [ "nginx", "-g", "daemon off;" ]
|
||||
|
||||
|
||||
# -g 'daemon off' :
|
||||
# daemon off, to avoid the main process of nginx to quit after creating its childs, and therefore make docker exit
|
||||
# https://stackoverflow.com/questions/18861300/how-to-run-nginx-within-a-docker-container-without-halting
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
server {
|
||||
# http uses port 80, and https uses port 443
|
||||
listen 443 ssl; # for ipv4.
|
||||
listen [::]:443 ssl; # for ipv6.
|
||||
|
||||
server_name localhost;
|
||||
location / {
|
||||
root /data/www;
|
||||
|
||||
@@ -1,50 +1,52 @@
|
||||
user www-data;
|
||||
worker_processes auto;
|
||||
pid /run/nginx.pid;
|
||||
include /etc/nginx/modules-enabled/*.conf;
|
||||
# doc : https://nginx.org/en/docs/dirindex.html
|
||||
|
||||
events {
|
||||
worker_connections 768;
|
||||
user www-data; # process owner name, can be anything
|
||||
worker_processes auto; # a worker is a process that handles incoming requests, auto to automatically adjust the number of processes available
|
||||
pid /run/nginx.pid; # defines a file that will store the process id of the main process
|
||||
include /etc/nginx/modules-enabled/*.conf; # include a file
|
||||
|
||||
events { # section for connection processing directives
|
||||
worker_connections 768; # max number of connection that can be opened by a worker process
|
||||
# multi_accept on;
|
||||
}
|
||||
|
||||
http {
|
||||
http { # section for http server directives
|
||||
##
|
||||
# Basic Settings
|
||||
##
|
||||
|
||||
sendfile on;
|
||||
tcp_nopush on;
|
||||
tcp_nodelay on;
|
||||
keepalive_timeout 65;
|
||||
types_hash_max_size 2048;
|
||||
sendfile on; # enable the use of linux sendfil() function, that transfer data directly betzeen fd, so withour copying to intermediate memory buffer, it increases performances in most cases (https://stackoverflow.com/questions/58066785/always-use-sendfile-with-nginx-on-linux)
|
||||
tcp_nopush on; # enables the socket option TCP_CORK/TCP_NOPUSH, that allows to send packets filled with more datas (https://baus.net/on-tcp_cork/)
|
||||
tcp_nodelay on; # opposit of TCP_CORK, TCP_NODELAY says the application to send datas as soon as it receives it, both options are exclusives but can work together in modern kernel (https://stackoverflow.com/questions/3761276/when-should-i-use-tcp-nodelay-and-when-tcp-cork)
|
||||
keepalive_timeout 65; # in seconds, defines time before closing a connexion without activity
|
||||
types_hash_max_size 2048; # maximum size for the list that stores duplicates of the hash table, size of the hash table is chosen accordingly (https://nginx.org/en/docs/hash.html, hash table : https://www.youtube.com/watch?v=KyUTuwz_b7Q)
|
||||
# server_tokens off;
|
||||
|
||||
# server_names_hash_bucket_size 64;
|
||||
# server_name_in_redirect off;
|
||||
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
include /etc/nginx/mime.types; # include a file
|
||||
default_type application/octet-stream; # defines the default MIME type (default is text/plain)
|
||||
|
||||
##
|
||||
# SSL Settings
|
||||
##
|
||||
|
||||
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_protocols TLSv1.2; # Dropping SSLv3, ref: POODLE # enables the specified protocols. The TLSv1.1 and TLSv1.2 parameters works only when OpenSSL 1.0.1 or higher is used, and the TLSv1.3 only when OpenSSL 1.1.1 or higher is used
|
||||
ssl_prefer_server_ciphers on; # Specifies that server ciphers should be preferred over client ciphers when using the SSLv3 and TLS protocols (a cipher is "an algorithm for performing encryption or decryption, a series of [...] steps that can be followed as a procedure" https://en.wikipedia.org/wiki/Cipher_suite)
|
||||
|
||||
##
|
||||
# Logging Settings
|
||||
##
|
||||
|
||||
access_log /var/log/nginx/access.log;
|
||||
error_log /var/log/nginx/error.log;
|
||||
access_log /var/log/nginx/access.log; # defines where to write the access logs. if gzip is used, the log will be buffered
|
||||
error_log /var/log/nginx/error.log; # defines where to write the error logs. if gzip is used, the log will be buffered
|
||||
|
||||
##
|
||||
# Gzip Settings
|
||||
##
|
||||
|
||||
gzip on;
|
||||
gzip on; # enable gzipping of responses. gzip is an algorithm that compress the data
|
||||
|
||||
# gzip_vary on;
|
||||
# gzip_proxied any;
|
||||
@@ -57,8 +59,8 @@ http {
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
include /etc/nginx/sites-enabled/*;
|
||||
include /etc/nginx/conf.d/*.conf; # include the *.conf files found in conf.d folder. do the same as "sites-enabled" with another approach : you put your .conf files for the site inside this folder, and if you want to disable a config file you just rename it to no have a .conf suffix
|
||||
# include /etc/nginx/sites-enabled/*; # include all the (symlink) files found in sites-enabled folder. do the same as "conf.d" with another approach : you put all your configurations files into a "/etc/nginx/sites-available/" folder, and you put symlinks of a selection of thoses files that you want to use for the site, into "/etc/nginx/sites-enabled/" folder (bad practice : https://serverfault.com/questions/527630/difference-in-sites-available-vs-sites-enabled-vs-conf-d-directories-nginx#answer-870709)
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user