Last active
January 30, 2022 16:52
-
-
Save AlekseyArh/49eaf80b3ab35ebc80f30645e8624670 to your computer and use it in GitHub Desktop.
nginx.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
events { | |
# Устанавливает максимальное количество соединений одного рабочего процесса | |
worker_connections 1024; | |
# Будет принимать максимально возможное количество соединений | |
multi_accept on; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http { | |
# Кодировка по-умолчанию | |
charset utf-8; | |
# Показывать ли версию nginx | |
server_tokens off; | |
# Метод отправки данных sendfile более эффективен, чем стандартный метод read+write | |
sendfile on; | |
# Если клиент прекратит чтение ответа, Nginx подождет 2 секунды и сбросит соединение | |
send_timeout 2; | |
# В этом случае сервер не будет принимать запросы размером более 1Мб | |
client_max_body_size 1m; | |
# Будет ждать 10 секунд тело запроса от клиента, после чего сбросит соединение | |
client_body_timeout 10; | |
# Если клиент перестал читать отвечать, Nginx будет сбрасывать соединение с ним | |
reset_timedout_connection on; | |
# Будет ждать 30 секунд перед закрытием keepalive соединения | |
keepalive_timeout 30; | |
# Максимальное количество keepalive запросов от одного клиента | |
keepalive_requests 50; | |
# Будет отправлять заголовки и начало файла в одном пакете | |
tcp_nopush on; | |
tcp_nodelay on; | |
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_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE | |
ssl_prefer_server_ciphers on; | |
# Основной лог лучше отключить для экономии дисковых операций | |
#access_log /var/log/nginx/access.log; | |
access_log off; | |
# Лог ошибок лучше перевести в режим логирования только критических ситуаций | |
#error_log /var/log/nginx/error.log; | |
error_log /var/log/nginx/error.log crit; | |
# Будет сжимать все файлы с перечисленными типами | |
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; | |
# Определение устройства | |
map $http_user_agent $device { | |
default 'desktop'; | |
~*(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge\ |maemo|midp|mmp|mobile.+firefox|netfront|opera\ m(ob|in)i|palm(\ os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows\ ce|xda|xiino/i 'mobile'; | |
~*android|ipad|playbook|silk/i 'tablet'; | |
} | |
# Запрет склейки слэшов | |
merge_slashes off; | |
# Подключение настроек виртуальных хостов | |
include /etc/nginx/sites-enabled/*.conf; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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; | |
# } | |
#} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream backend { | |
server backend1.example.com weight=5; | |
server 127.0.0.1:8080 max_fails=3 fail_timeout=30s; | |
server unix:/tmp/backend3; | |
server backup1.example.com backup; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Пользователь, от которого работает nginx | |
user nginx; | |
# Определяет количество рабочих процессов. Его лучше устанавливать в auto в новых версиях | |
worker_processes auto; | |
# Файл процесса nginx | |
pid /run/nginx.pid; | |
# Подключение модулей | |
include /etc/nginx/modules-enabled/*.conf; | |
# Подключение главных директив | |
include /etc/nginx/conf.d/*.conf; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment