您的位置:首页 > 运维架构 > Nginx

nginx 配置

2016-01-13 00:00 513 查看
#user nobody;worker_processes 1; #有1个工作的子进程,可以自行修改,但太大无益,因为要争夺CPU,一般设置为 CPU数*核数#error_log logs/error.log;#error_log logs/error.log notice;#error_log logs/error.log info;#pid logs/nginx.pid;events {

#一般是配置nginx链接的特性

#一个worker 能同时连接1024个链接
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

#main的格式 记录的 remote_addr.... http_x_forwarded_for等选项.

#1: 日志格式 是指记录哪些选项
#默认的日志格式: main
# log_format main '$remote_addr - $remote_user [$time_local] #"$request" '
# '$status $body_bytes_sent #"$http_referer" '
# '"$http_user_agent" #"$http_x_forwarded_for"';

#如默认的main日志格式,记录这么几项
#远程IP- 远程用户/用户时间 请求方法(如GET/POST) 请求体body长度 #referer来源信息
#http-user-agent用户代理/蜘蛛 ,被转发的请求的原始IP
#
#http_x_forwarded_for:在经过代理时,代理把你的本来IP加在此头信息中#,传输你的原始IP
#
#
#
#2: 声明一个独特的log_format并命名
#
# log_format mylog '$remote_addr- "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" #"$http_x_forwarded_for"';
#在下面的server/location,我们就可以引用 mylog
#Nginx允许针对不同的server做不同的Log ,(有的web服务器不支#持,如lighttp)

#access_log logs/access_8080.log mylog;
#声明log log位置 log格式;

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

#gzip on;

server {
listen 80;
server_name localhost;

#charset koi8-r;

#这说明 该server, 它的访问日志的文件是 logs/host.access.log ,
#使用的格式”main”格式.
#除了main格式,你可以自定义其他格式.

#access_log logs/host.access.log main;

#location = patt {} [精准匹配]
#location patt{} [一般匹配]
#location ~ patt{} [正则匹配]

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

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

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

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: