#启动子进程程序默认用户
#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. Flask入门文件上传flask-uploads(八)

    1 视图传递多个参数 (1) 普通传参 : 关键字参数传递 return render_template('模板名称.html',arg1=val1,arg2=val2...) (2) 字典传参 : ...

  2. (EXPDP) Fails With Errors ORA-39079 ORA-25306 On One Node In RAC Environment

    分类: Oracle DataPump export on one certain RAC instance fails with errors: ORA-39006: internal errorO ...

  3. selenium使用js进行点击

    WebElement button = driver.findElement(By.xpath("/html/body/div[1]/div[3]/h2/div[2]")); Ja ...

  4. Apache轻量级性能測试工具--ab

    Apache轻量级性能測试工具--ab ab早已不是什么新奇玩意,平时工作中会须要一些性能測试.简单的性能測试全然能够由AB来替代,而不须要动用LR这样重量级的工具. 此文简介一下ab的工具使用与结果 ...

  5. POJ 3461 Oulipo 【KMP统计子串数】

    传送门:http://poj.org/problem?id=3461 Oulipo Time Limit: 1000MS   Memory Limit: 65536K Total Submission ...

  6. 2018.10.31 Mac下的Mysql修改字符编码修改的问题总结

    今天在弄数据库的时候发现存入中文汉字变成了问号,Mac跟windows处理方式不一样. show variables like '%char%'; 查看当前mysql的编码格式 也就是默认编码格式 + ...

  7. Android学习笔记_65_登录功能本身没有任何特别

    对于登录功能本身没有任何特别,使用httpclient向服务器post用户名密码即可.但是为了保持登录的状态(在各个Activity之间切换时要让网站知道用户一直是处于登录的状态)就需要进行cooki ...

  8. HTML5标签应用

    <!doctype html> <html> <head> <style> /* *{border:1px solid red;height:20px} ...

  9. 【题解】洛谷P1313 [NOIP2011TG]计算系数(组合+二次项展开)

    洛谷P1313:https://www.luogu.org/problemnew/show/P1313 思路 本题就是考查二次项展开 根据定理有:(ax+by)k=∑ki=0Cik*aibk-ixiy ...

  10. 让网页显示ajax的查询数据

    今天下午做一个项目小练习.需要把查询日志的内容显示到网页上来.一开始陷入了一个误区. 一直以来我这个小项目需要访问ashx来生成html的代码.后台用的Razor模板引擎. 刚开始显示用户列表时.因为 ...