170816、nginx常用配置说明
#user nobody; #开启进程数 <=CPU数
worker_processes 1; #错误日志保存位置
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #进程号保存文件
#pid logs/nginx.pid; #每个进程最大连接数(最大连接=连接数x进程数)每个worker允许同时产生多少个链接,默认1024
events {
worker_connections 1024;
} http {
#文件扩展名与文件类型映射表
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 on;
#tcp_nopush on; #keepalive_timeout 0;
#连接超时时间
keepalive_timeout 65; #打开gzip压缩
#gzip on; #设定请求缓冲
#client_header_buffer_size 1k;
#large_client_header_buffers 4 4k; #设定负载均衡的服务器列表
#upstream myproject {
#weigth参数表示权值,权值越高被分配到的几率越大
#max_fails 当有#max_fails个请求失败,就表示后端的服务器不可用,默认为1,将其设置为0可以关闭检查
#fail_timeout 在以后的#fail_timeout时间内nginx不会再把请求发往已检查出标记为不可用的服务器
#} #webapp
#upstream myapp {
# server 192.168.1.171:8080 weight=1 max_fails=2 fail_timeout=30s;
# server 192.168.1.172:8080 weight=1 max_fails=2 fail_timeout=30s;
#} #配置虚拟主机,基于域名、ip和端口
server {
#监听端口
listen 80;
#监听域名
server_name localhost; #charset koi8-r; #nginx访问日志放在logs/host.access.log下,并且使用main格式(还可以自定义格式)
#access_log logs/host.access.log main; #返回的相应文件地址
location / {
#设置客户端真实ip地址
#proxy_set_header X-real-ip $remote_addr;
#负载均衡反向代理
#proxy_pass http://myapp; #返回根路径地址(相对路径:相对于/usr/local/nginx/)
root html;
#默认访问文件
index index.html index.htm;
} #配置反向代理tomcat服务器:拦截.jsp结尾的请求转向到tomcat
#location ~ \.jsp$ {
# proxy_pass http://192.168.1.171:8080;
#} #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;
#}
} #虚拟主机配置:
server {
listen 1234;
server_name bhz.com;
location / {
#正则表达式匹配uri方式:在/usr/local/nginx/bhz.com下 建立一个test123.html 然后使用正则匹配
#location ~ test {
## 重写语法:if return (条件 = ~ ~*)
#if ($remote_addr = 192.168.1.200) {
# return 401;
#} #if ($http_user_agent ~* firefox) {
# rewrite ^.*$ /firefox.html;
# break;
#} root bhz.com;
index index.html;
} #location /goods {
# rewrite "goods-(\d{1,5})\.html" /goods-ctrl.html;
# root bhz.com;
# index index.html;
#} #配置访问日志
access_log logs/bhz.com.access.log main;
} # 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;
# }
#} }
170816、nginx常用配置说明的更多相关文章
- nginx 常用配置说明
一.location 配置 1.1 语法规则: location [=|~|~*|^~] /uri/ { … }= 开头表示精确匹配^~ 开头表示uri以某个常规字符串开头,理解为匹配 url路径即可 ...
- nginx常用配置说明
nginx的主配置(nginx.conf)说明 #worker进程数量 worker_processes 1; #错误日志 error_log logs/error.log; #进程ID文件 pid ...
- nginx的重试机制以及nginx常用的超时配置说明
nginx的重试机制 现在对外服务的网站,很少只使用一个服务节点,而是部署多台服务器,上层通过一定机制保证容错和负载均衡. nginx就是常用的一种HTTP和反向代理服务器,支持容错和负载均衡. ng ...
- 【Linux】nginx常用命令
相关内容链接 Centos之安装Nginx及注意事项 [nginx]详细配置说明 nginx常用命令 [重新加载配置]sudo nginx -s reload [打开nginx配置]sudo vim ...
- Nginx常用功能配置一
Nginx常用功能配置 参数include配置 说明:如果日常工作中server标签存在太多,可以采用include配置模式,Nginx的主配置文件包含的所有虚拟主机的子配置文件会统一放入extra目 ...
- Nginx 常用全局变量 及Rewrite规则详解
每次都很容易忘记Nginx的变量,下面列出来了一些常用 $remote_addr //获取客户端ip $binary_remote_addr //客户端ip(二进制) $remote_port //客 ...
- nginx 常用的 URL 重写方法
转自:http://www.jbxue.com/article/4727.html Nginx中一些常用的URL 重写方法介绍,有需要的朋友可以参考下.url重写应该不陌生,不管是SEO URL 伪静 ...
- 3.Nginx常用功能介绍
Nginx常用功能介绍 Nginx反向代理应用实例 反向代理(Reverse Proxy)方式是指通过代理服务器来接受Internet上的连接请求,然后将请求转发给内部网络上的服务器,并且从内部网络服 ...
- Nginx常用配置实例(4)
Nginx作为一个HTTP服务器,在功能实现方面和性能方面都表现得非常卓越,完全可以与Apache相媲美,几乎可以实现Apache的所有功能,下面就介绍一些Nginx常用的配置实例,具体包含虚拟主机配 ...
随机推荐
- SQL 语句判断记录是否存在(最简洁简单性能最优)
今天查了下,发现网上的没有一个sql语句写的好的. 判断记录是否存在,要不是语句不够简洁,要不就是性能有很大问题. 我进行了优化后,最简洁简单性能最优的的sql语句,用来判断表中的记录是否存在: se ...
- 【Oracle】BLOB
1.データベースからの読み込み Dim strSql As String = "select IMG from TBL where ID=XX" Dim cmd As New Or ...
- express不是内部或外部命令,也不是可运行的程序或批处理文件
如上安装了express以后,仍然报如下错误:express不是内部或外部命令,也不是可运行的程序或批处理文件 原因是版本问题:当前版本是4.0.0,改成3.5.0即可运行. npm install ...
- 开源CMS的比较和选择
最近就cms系统折腾了一下,主要还是以 构架为主,以下做一个大概的比较: 1. Nuke 一般称为DNN,这是最开始Microsoft发布 的时候,用vb做了一个web的演示例子,最终这个例子发展成了 ...
- MongoDB 数据管理
MongoDB 相关操作: > db.version() // 查看 MongoDB 版本 > db.serverStatus() // 查看 MongoDB 服务器的状态 MongoDB ...
- Theme.AppCompat.Light的解决方法
style name=”AppBaseTheme” parent=”Theme.AppCompat.Light” 改为 改为 style name=”AppBaseTheme” parent=”and ...
- iOS - Action Extension
上一篇<iOS开发 之 Share Extension>介绍了分享扩展的开发与使用,本篇主要还是讲述在系统分享菜单中最底下一栏的功能扩展:Action Extension,该扩展跟Shar ...
- 执行Batch批处理遇到的问题
1.务必关掉自动提交 增强执行效率 conn.setAutoCommit(false); 2.executeBatch失效问题 <1>务必将语句pstmt = conn.prepareSt ...
- 转 Mysql性能优化教程
Mysql性能优化教程 背景及目标 厦门游家公司(4399.com)用于员工培训和分享. 针对用户群为已经使用过mysql环境,并有一定开发经验的工程师 针对高并发,海量数据的互联网环境. 本文语言为 ...
- U盘安装centos7:不能载入到安装界面
在用U盘安装centos7时,我们需要修改镜像位置: 选择第一项:Install CentOS 7 ,按 e(也有可能是tab键)键进入编辑界面. 将 vmlinuz initrd=initrd.im ...