Nginx部署文件(一)-nginx.conf文件

摘要:
1、 默认文件描述1.以nginx/1.14.0(Ubuntu)为例。1#用户和组2userwww数据;3#定义nginx外部提供web服务时的工作进程数4个worker_processesauto;5#指定存储pid的路径。它应该记录nginx守护进程的进程号,这是其他进程的父进程ID!(例如,Apache下有一个PidFile)6pid/run/nginx。pid;7包括/等
一,默认文件说明

1.以nginx/1.14.0 (Ubuntu)为例

 1 # 使用的用户和组
 2 user www-data;
 3 # 定义nginx对外提供web服务时的worker进程数
 4 worker_processes auto;
 5 # 指定pid存放的路径,应该记录了nginx守护进程的进程号,是其他进程的父进程id!(如Apache下有PidFile )
 6 pid /run/nginx.pid;
 7 include /etc/nginx/modules-enabled/*.conf;
 8 
 9 events {
10     worker_connections 768;  # 允许的最大连接数
11     # multi_accept on;       # 收到一个新连接通知后接受尽可能多的连接
12 }
13 
14 http {
15 
16     ##
17     # Basic Settings 基本设置
18     ##
19 
20     sendfile on;               # 开启sendfile()数据缓冲,请保持默认打开
21     tcp_nopush on;             # 发送所有头文件
22     tcp_nodelay on;            # 及时发送数据
23     keepalive_timeout 65;      # 请求超过时间
24     types_hash_max_size 2048;  #散列表的冲突率,types_hash_max_size越大,就会消耗更多的内存,但散列key的冲突率会降低,检索速度就更快。
25     # server_tokens off;       # 关闭在错误页面中的nginx版本数字,有利于安全
26 
27     # server_names_hash_bucket_size 64;
28     # server_name_in_redirect off;
29 
30     include /etc/nginx/mime.types;          # 加载MIME类型
31     default_type application/octet-stream;  # 设置文件使用的默认的MIME-type
32                                             #charset UTF-8; 设置我们的头文件中的默认的字符集
33     ##
34     # SSL Settings SSL设置
35     ##
36 
37     ssl_protocols TLSv1 TLSv1.1 TLSv1.2;  # Dropping SSLv3, ref: POODLE
38     ssl_prefer_server_ciphers on;
39 
40     ##
41     # Logging Settings 日志设置
42     ##
43 
44     access_log /var/log/nginx/access.log;  # 存储访问日志,关闭这个选项可以让读取磁盘IO操作更快
45     error_log /var/log/nginx/error.log;    # 记录错误信息
46 
47     ##
48     # Gzip Settings Gzip压缩设置
49     ##
50 
51     gzip on;                  #采用gzip压缩的形式发送数据
52 
53     # gzip_vary on;           #针对相同url,可以根据头信息返回压缩和非压缩副本 
54     # gzip_proxied any;       #any代表压缩所有的请求
55     # gzip_comp_level 6;      #设置数据的压缩等级,1-9 9最慢
56     # gzip_buffers 16 8k;     #如果没有设置,默认值是申请跟原始数据相同大小的内存空间去存储gzip压缩结果。
57     # gzip_http_version 1.1;  #值为1.0和1.1 代表是否压缩http协议1.0,选择1.0则1.0和1.1都可以压缩 
58     # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;  #设置需要压缩的数据格式
59 
60     ##
61     # Virtual Host Configs 
62     ##
63     # 加载conf.d目录与sites-enabled目录下得配置文件
64     include /etc/nginx/conf.d/*.conf;
65     include /etc/nginx/sites-enabled/*;
66 }
67 
68 # 邮件代理服务器
69 #mail {
70 #    # See sample authentication script at:
71 #    # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
72 # 
73 #    # auth_http localhost/auth.php;
74 #    # pop3_capabilities "TOP" "USER";
75 #    # imap_capabilities "IMAP4rev1" "UIDPLUS";
76 # 
77 #    server {
78 #        listen     localhost:110;
79 #        protocol   pop3;
80 #        proxy      on;
81 #    }
82 # 
83 #    server {
84 #        listen     localhost:143;
85 #        protocol   imap;
86 #        proxy      on;
87 #    }
88 #}

  更多配置属性见:https://blog.csdn.net/xifeijian/article/details/20956605;https://blog.51cto.com/blief/1736849;https://www.iteye.com/blog/phl-1979082

二,配置实例 三,负载均衡

免责声明:文章转载自《Nginx部署文件(一)-nginx.conf文件》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇centos coreseek 快速安装WebService开发实例(Axis2实现,无需安装,快速实现)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

shell脚本之nginx的安装

       为了编写nginx自动部署的脚本而刚学习的shell脚本语言。写文章只是为了记录,有错误勿喷。 一、创建shell脚本程序        操作系统是Linux的 CentOS 7 版本。解释器默认使用 bash 。        首先是使用vim命令创建一个shell脚本程序。            vim nginx-install.sh ...

Nginx跨域及Https配置

一、跨域 1. 什么是跨域? 跨域:指的是浏览器不能执行其他网站的脚本。它是由浏览器的同源策略造成的,是浏览器对javascript施加的安全限制(指一个域下的文档或脚本试图去请求另一个域下的资源,这里跨域是广义的) 例如:a页面想获取b页面资源,如果a、b页面的协议、域名、端口、子域名不同,所进行的访问行动都是跨域的,而浏览器为了安全问题一般都限制了跨域...

Nginx深度优化

简介 1.隐藏版本号2.修改Nginx用户与组3.配置Nginx网页缓存时间4.实现Nginx的日志切割5.配置Nginx实现连接超时6.更改进程数7.配置Nginx实现网页压缩功能8.配置Nginx实现防盗链9.FPM模块进行参数优化 实验环境 系统环境:CentOS7.4 服务器IP地址:192.168.100.71 客户端IP地址:192.168....

运维配置环境中间件

日常Linux运维环境配置笔记---不定期更新 声明:本文为个人维护笔记,当中的例子或者步骤都是借鉴网络上的方法或者方案,后自己一步步的进行试验后得出来的。有可能会写错,也有可能是缺少某部分没有记录,如发现请大家指出。谢谢 版权声明:本文为博主原创文章,未经博主允许不得转载。 1.环境建立 输入用户、密码登录Luinx 查看网络情况如何,有没有加载网...

nginx 流量拷贝模块 ngx_http_mirror_module 安装试用

1. 下载源码编译 https://nginx.org/download/nginx-1.13.4.tar.gz 2. 下载依赖模块包 这里直接yum 安装 yum -y install openssl openssl-devel yum -y install pcre-devel 3. 安装 可以直接默认 ./configure 我是为了添加htt...

Nginx 配置访问静态资源

做个简单的配置: 以txt/png/mp4结尾的请求都会按照如下规则寻找返回文件 关键词: location、root location ~ .(mp4|png|txt) {   root /usr/local/tomcat9/webapps/scm;   autoindex on; } 主义root代表的是替换请求URL中域名的值,如请求的URL为...