#user  nobody;

#启动进程数,即启动ngnix服务的个数,通常设置和cpu的数量相等
worker_processes 1; #全局错误日志及PID文件
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #nginx进程ID
#pid logs/nginx.pid; events { #单个后台worker process进程的最大并发链接数
# 并发总数是 worker_processes 和 worker_connections 的乘积
# 即 max_clients = worker_processes * worker_connections
worker_connections 1024;
} http { #设定mime类型,类型由mime.type文件定义 include mime.types;
default_type application/octet-stream; #访问日志格式
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #当前虚拟机的访问日志
#access_log logs/access.log main; #sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,
#功能是优化文件拷贝,提高web sever性能
#对于普通应用,必须设为 on,
#如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,
#以平衡磁盘与网络I/O处理速度,降低系统的uptime.
sendfile on;
#tcp_nopush on; #keepalive 维持http连接时间
#keepalive_timeout 0;
keepalive_timeout 65; #默认情况下,gzip压缩是关闭的,该功能是面向客户端的, gzip压缩功能是减少带宽,但会增加服务器CPU的开销,Nginx默认只对text/html进行压缩 ,如果要对html之外的内容进行压缩传输,我们需要手动来调。
#gzip on; #配置虚拟主机
server { #虚拟主机端口
listen 8098;
#虚拟主机域名
server_name localhost; #字符编码
#charset koi8-r;
#访问日志
#access_log logs/host.access.log main; #代理
location / {
root source/electric;
index index.html index.htm;
proxy_pass http://myapp; #代理地址,指向上面的myapp
} #404错误提示页
#error_page 404 /404.html; #服务端错误提示页
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} ########以下是配置php代理############
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} #一个ngxin可以配置多个虚拟主机,配置同上
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} ##############配置https server##############
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

Nginx配置文件分析的更多相关文章

  1. nginx 配置文件分析以及配置负载均衡器

    修改Nginx核心配置文件nginx.conf # cat /usr/local/nginx/conf/nginx.conf user www www; worker_processes ; # 工作 ...

  2. Nginx源码研究六:NGINX的配置文件分析

    上一篇写到nginx的各个模块的配置信息的存储结构,大体描述了对配置信息的配置项生成,定制,初始化过程.这里重点研究实现定制的过程,所谓实现定制,这里指的是,nginx系统提供使用者定义nginx的配 ...

  3. nginx源代码分析--配置文件解析

    ngx-conf-parsing 对 Nginx 配置文件的一些认识: 配置指令具有作用域,分为全局作用域和使用 {} 创建其他作用域. 同一作用域的不同的配置指令没有先后顺序:同一作用域能否使用同样 ...

  4. nginx日志分析利器GoAccess

    面试的时候一定会被面到的问题是:给出web服务器的访问日志,请写一个脚本来统计访问前10的IP有哪些?访问前10的请求有哪些?当你领略过goaccess之后,你就明白,这些问题,除了考验你的脚本背诵记 ...

  5. 使用elk+redis搭建nginx日志分析平台

    elk+redis 搭建nginx日志分析平台 logstash,elasticsearch,kibana 怎么进行nginx的日志分析呢?首先,架构方面,nginx是有日志文件的,它的每个请求的状态 ...

  6. NGINX userid 分析、解码

    NGINX userid 分析.解码 生成userid的代码在 http/modules/ngx_http_userid_filter_module.c 大概550行左右. uid_set 是4个ui ...

  7. nginx配置文件中的location理解

    关于一些对location认识的误区 1. location 的匹配顺序是"先匹配正则,再匹配普通". 矫正: location 的匹配顺序其实是"先匹配普通,再匹配正则 ...

  8. Nginx源代码分析—业务流程

    Nginx源代码分析-业务流程 到此为止,我们如果ngx_init_cycle已经结束.我们临时无论他做了什么,我们从他做的效果进入. 从常理上来讲,假设一个请求到达,那么我们须要接受这个请求,那么就 ...

  9. nginx日志分析利器GoAccess(转)

    面试的时候一定会被面到的问题是:给出web服务器的访问日志,请写一个脚本来统计访问前10的IP有哪些?访问前10的请求有哪些?当你领略过goaccess之后,你就明白,这些问题,除了考验你的脚本背诵记 ...

随机推荐

  1. 常见数据结构图文详解-C++版

    目录 简介 一.数组 1. 静态数组 array 2. 动态数组 2.1. vector 2.2. priority_queue 2.3. deque 2.4. stack 2.5. queue二.单 ...

  2. 课时5:闲聊之Python的数据类型

    目录: 一.引言 二.数据类型 >整型 >浮点型 >布尔类型 三.类型转换 四.获得关于类型的信息 五.课时05课后习题及答案 *********** 一.引言 ********** ...

  3. FTP数字代码的意义

    110 重新启动标记应答.120 服务在多久时间内ready.125 数据链路端口开启,准备传送.150 文件状态正常,开启数据连接端口.200 命令执行成功.202 命令执行失败.211 系统状态或 ...

  4. linux 环境下mysql忽略大小写

    mysql数据库在window环境下默认是忽略大小写的,而linux环境中则相反,数据库移植过去后可能会影响到应用工程的正常使用. 解决方法: 用root帐号登录后,在/etc/my.cnf 中的[m ...

  5. JavaWeb笔记(四)Cookie&Session

    Cookie 客户端会话技术,客户端保存,用于存储少量不太敏感的数据,在不登陆的情况下完成服务器对客户端的身份识别 简单使用步骤 创建Cookie对象,绑定数据 new Cookie(String n ...

  6. table不让td中文字溢出操作方法

    table不让td中文字溢出操作方法 table{ width:100px; table-layout:fixed;/* 只有定义了表格的布局算法为fixed,下面td的定义才能起作用. */ } t ...

  7. Java9最受期待的5大新特性

    虽然Java9要等到明年才正式发布,但是现在网上已经有了各种各样的有关Java9新特性的文章了,今天小编也将为大家分享除了通常猜测之外的一些很值得期待的5个新特性. 1.Java + REPL = j ...

  8. 在有道词典程序文件夹发现一个后缀名为sql的数据库(SQLite)

    缘起 在清理电脑磁盘的时候,看一看各安装文件夹有占用了多大容量,发现有道词典居然达140MB了,于是进去看看. 发现个有趣的文件:XXX.sql. 首先我们看一看它的安装文件夹的结构: Dict └─ ...

  9. Windows1小时后关机命令

    shutdown -s -t 3600 1.注销当前用户 shutdown - l 该命令只能注销本机用户,对远程计算机不适用. 2.关闭本地计算机 shutdown - s 3.重启本地计算机 sh ...

  10. 原生方法scrollTo支持滚动特效

    scrollTo默认的是瞬间滚动到坐标位置, 使用配置方法, behavior属性设置为smooth就可以支持平滑滚动了,不过这种方法兼容性不行,并且无法支持配置滚动速率 // 默认滚动效果,瞬时滚动 ...