博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nginx配置文件分析
阅读量:4608 次
发布时间:2019-06-09

本文共 3469 字,大约阅读时间需要 11 分钟。

#user  nobody;#启动进程数,即启动ngnix服务的个数,通常设置和cpu的数量相等worker_processes  1;#全局错误日志及PID文件#error_log  logs/error.log;#error_log  logs/error.log  notice;#error_log  logs/error.log  info;#nginx进程ID#pid        logs/nginx.pid;events {    #单个后台worker process进程的最大并发链接数    # 并发总数是 worker_processes 和 worker_connections 的乘积    # 即 max_clients = worker_processes * worker_connections    worker_connections  1024;}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"';        #当前虚拟机的访问日志    #access_log  logs/access.log  main;    #sendfile 指令指定 nginx 是否调用 sendfile 函数(zero copy 方式)来输出文件,    #功能是优化文件拷贝,提高web sever性能    #对于普通应用,必须设为 on,    #如果用来进行下载等应用磁盘IO重负载应用,可设置为 off,    #以平衡磁盘与网络I/O处理速度,降低系统的uptime.    sendfile        on;    #tcp_nopush     on;    #keepalive 维持http连接时间    #keepalive_timeout  0;    keepalive_timeout  65;    #默认情况下,gzip压缩是关闭的,该功能是面向客户端的, gzip压缩功能是减少带宽,但会增加服务器CPU的开销,Nginx默认只对text/html进行压缩 ,如果要对html之外的内容进行压缩传输,我们需要手动来调。    #gzip  on;    #配置虚拟主机    server {            #虚拟主机端口        listen       8098;        #虚拟主机域名        server_name  localhost;        #字符编码        #charset koi8-r;        #访问日志        #access_log  logs/host.access.log  main;        #代理        location / {            root   source/electric;            index  index.html index.htm;            proxy_pass  http://myapp; #代理地址,指向上面的myapp        }        #404错误提示页        #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;        }        ########以下是配置php代理############        # 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;        #}    }    #一个ngxin可以配置多个虚拟主机,配置同上    # 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##############    # 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;    #    }    #}}

转载于:https://www.cnblogs.com/yanfei1819/p/8657035.html

你可能感兴趣的文章
Scrum立会报告+燃尽图(Beta阶段第二周第二次)
查看>>
动态代理
查看>>
WCF 中,出现The remote server returned an unexpected response: (400) Bad Request.
查看>>
缓存概要
查看>>
vue项目中使用百度地图的方法
查看>>
[Vue-rx] Stream an API using RxJS into a Vue.js Template
查看>>
[Javascript] lodash: memoize() to improve the profermence
查看>>
手写符合Promise/A+规范的Promise
查看>>
JPA、JTA、XA相关索引
查看>>
查询语句的练习
查看>>
Java EE的map
查看>>
webdriver.py--解说
查看>>
windows 下配置Eclipse che
查看>>
SearchSploit
查看>>
关于C语言中的转义字符
查看>>
用正则表达式从网页里面提取视频地址
查看>>
JAVA线程优先级
查看>>
解决VC几个编译问题的方法——好用
查看>>
SPOJ #11 Factorial
查看>>
City Upgrades
查看>>