#登录用户
#user nobody;
worker_processes 4;
#工作进程的数量,建议工作进程和cpu核心一致
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
#events 全局块,可以连接的进程数
events {
worker_connections 1024;
}
#http全局块
http {
include mime.types;
default_type application/octet-stream;
#隐藏nginx的版本
server_tokens off;
#$开头的都是变量,以什么格式存入log,比如$remote_addr表示访问本机的ip地址,..._user访问的用户
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 on;
#tcp_nopush on;
#keepalive_timeout 0;
#连接超时时间
keepalive_timeout 65;
#超时时间65秒,连接后65秒不发起新的连接请求,
这个连接就会断开
gzip on;
upstream scapp{
server 192.168.136;
server 192.168.142;
}
#server块,提供web服务
server {
listen 80;
#监听端口号80
server_name localhost;
#网站服务的域名
#charset koi8-r;
#使用的字符集
#access_log logs/host.access.log main;
#访问日志的路径和格式
location / {
#提供某个路由的配置,访问网站的根目录
root html;
#打开网站下载功能
autoindex on;
#html是存放网页的根目录
index index.html index.htm;
} #指定网页
#访问192.168.174.143/status 返回nginx内部
的状态统计 --》并发数
location /status {
auth_basic "sancahung site";
#对访问网站进行加密
auth_basic_user_file htpasswd;
stub_status;
}
#error_page 404 /404.html;
#错误页面,访问不到网页的时候,会给用户返
回这个页面