#启动子进程程序默认用户
#user nobody;
#一个主进程和多个工作进程。工作进程是单进程的,且不需要特殊授权即可运行;这里定义的是工作进程数量
worker_processes 1;

#全局错误日志的位置及日志格式
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

#pid logs/nginx.pid;

events {
#每个工作进程最大的并发数
worker_connections 1024;
}

#http服务器设置
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"';
#$remote_addr与$http_x_forwarded_for用以记录客户端的ip地址;
#$remote_user:用来记录客户端用户名称;
#$time_local: 用来记录访问时间与时区;
#$request: 用来记录请求的url与http协议;
#$status: 用来记录请求状态;成功是200,
#$body_bytes_sent :记录发送给客户端文件主体内容大小;
#$http_referer:用来记录从那个页面链接访问过来的;
#$http_user_agent:记录客户浏览器的相关信息;

#全局访问日志路径
#access_log logs/access.log main;
#sendfile指令指定 nginx 是否调用sendfile 函数(zero copy 方式)来输出文件,对于普通应用,必须设为on。如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络IO处理速度,降低系统uptime。
sendfile on;

#此选项允许或禁止使用socke的TCP_CORK的选项,此选项仅在使用sendfile的时候使用
#tcp_nopush on;

#长连接超时时间
#keepalive_timeout 0;
keepalive_timeout 65;

#开启压缩
#gzip on;

#配置虚拟主机
server {
#虚拟主机使用的端口
listen 80;
#虚拟主机域名
server_name localhost;

#虚拟主机支持的字符集
#charset koi8-r;

#虚拟主机的访问日志路径
#access_log logs/host.access.log main;

#定义web根路径
location / {
#根目录路径
root html;
#索引页
index index.html index.htm;
}

#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;
}

#定义反向代理服务器 数据服务器是lamp模型
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}

#定义PHP为本机服务的模型
# 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
#
#拒绝apache DR目录及子目录下的.htaccess文件访问
#location ~ /\.ht {
# deny all;
#}
}

# 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的配置方案
# 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;
# }
#}

}

03---Nginx配置文件的更多相关文章

  1. 【转】Nginx配置文件详细说明

    Nginx配置文件详细说明 在此记录下Nginx服务器nginx.conf的配置文件说明, 部分注释收集与网络. #运行用户user www-data;    #启动进程,通常设置成和cpu的数量相等 ...

  2. Etcd+Confd实现Nginx配置文件自动管理

    一.需求 我们使用Nginx做七层负载均衡,后端是Tomcat.项目采用灰度发布方式,每次项目升级,都要手动先从Nginx下摘掉一组,然后再升级这组,当项目快速迭代时,手动做这些操作显然会增加部署时间 ...

  3. Nginx配置文件nginx.conf中文详解(转)

    ######Nginx配置文件nginx.conf中文详解##### #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_ ...

  4. 查看nginx配置文件路径

    进入nginx安装目录(我的是/usr/local/nginx-1.7.8/) 进入sbin目录,输入 ./nginx -t查看nginx配置文件路径以及该文件语法是否正确 ./nginx -v查看n ...

  5. Nginx配置文件详解

    Nginx是一款面向性能设计的HTTP服务器,相较于Apache.lighttpd具有占有内存少,稳定性高等优势. ######Nginx配置文件nginx.conf中文详解##### #定义Ngin ...

  6. 005.nginx配置文件

    1.替换nginx主配置文件 通过前面的配置,LNMP的环境已经搭建完成,现在我们替换nginx配置文件: [root@huh ~]# cd /usr/local/nginx/conf/[root@h ...

  7. nginx配置文件nginx.conf超详细讲解

    #nginx进程,一般设置为和cpu核数一样worker_processes 4;                        #错误日志存放目录 error_log  /data1/logs/er ...

  8. 通过nginx配置文件抵御攻击

    通过nginx配置文件抵御攻击 囧思九千 · 2013/11/12 12:22 0x00 前言 大家好,我们是OpenCDN团队的Twwy.这次我们来讲讲如何通过简单的配置文件来实现nginx防御攻击 ...

  9. Nginx配置文件nginx.conf详细说明

    Nginx配置文件nginx.conf详细说明 #worker_processes 8; #worker_cpu_affinity 00000001 00000010 00000100 0000100 ...

  10. 一、Nginx配置文件详解

    配置文件介绍 主要有两部分:分别是 main:主体部分 http{}:虚拟主机配置部分 配置指令主要以分号结尾:配置语法:directive value1 [value2 ....] 支持使用的变量 ...

随机推荐

  1. Dynamics CRM RibbonWorkbench工具使用

    这边用的是RibbonWorkbench2016的工具,导入RibbonWorkbench2016解决方案即可.导入成功后在解决方案下面会多出一个快捷键小图标. 一.基本介绍 二.列表页获取选中记录的 ...

  2. C# 轻松读取、改变文件的创建、修改、访问时间 z

    // 读取文件的创建.修改.访问时间FileInfo fi = new FileInfo("C://test.txt");Console.WriteLine(fi.Creation ...

  3. Oracle SYS用户无法设置session级别的read only

    官方文档参考:SYSDBA is used internally in the Oracle database and has specialized functions. Its behavior ...

  4. makefile中的循环控制

    GNU make的foreach函数 foreach函数仅GNU make支持: 下面的代码中使用了函数foreach和shell files=main.exe a.exe b.exe all: ec ...

  5. SONA Topology

    N多年以前就有有人设计传了一种类似“房子”状结构的拓扑图,在Cisco的文档中可以查到这种叫SONA.这是个非常神奇的设计,适合用于中小型网络,之所以这么讲,是因为在这个结构下,但凡任何一台接入层或者 ...

  6. Jmeter入门9 __digest函数 jmeter字符串连接与登录串加密应用

     登录请求中加密串是由多个子串连接,再加密之后传输. 参数连接:${var1}${var2}${var3} 加密函数:__digest    (函数助手里如果没有该函数,请下载最新版本的jmeter5 ...

  7. 【转载】#443 - An Interface Cannot Contain Fields

    An interface can contain methods, properties, events or indexers. It cannot contain fields. interfac ...

  8. ubuntu桌面

    gnome-desktop-item-edit ~/Desktop/  --create-new

  9. Android学习笔记_59_清除sdcard缓存

    对于手机来说,每个软件在安装时,都会在sdcard上创建一个目录,用于缓存文件.市场上针对这些软件,统一了它的sdcard上的目录,将缓存目录存放到数据库中.如果要清理,可以根据当前应用包的名称,到数 ...

  10. 【题解】洛谷P2926 [USACO08DEC]拍头Patting Heads

    洛谷P2926:https://www.luogu.org/problemnew/show/P2926 思路 对于每一个出现的数 从1到Max 凡是这个数的倍数 那么ans就加上他的个数 PS:最后要 ...