• nginx配置文件


    nginx配置文件路径

    /etc/nginx/nginx.conf  可能包括/etc/nginx/conf.d/default.conf

    配置文件主要由四部分组成:main(全局配置),server(主机配置),upstream(负载均衡服务器设置),和location(URL匹配特定位置设置)。

    user  nginx;
    #Nginx用户及组:用户 组。window下不指定 worker_processes
    1; #工作进程:数目。根据硬件调整,通常等于CPU数量或者2倍于CPU。 error_log /var/log/nginx/error.log warn;
    #错误日志:存放路径 日志等级 pid
    /var/run/nginx.pid;
    #pid(进程标识符):存放路径。

    #事件配置
    events { 
        worker_connections  1024;
    #每个工作进程的最大连接数量。需要根据硬件调整,和前面工作进程配合起来用,尽量大,但是别把cpu跑到100%就行。每个进程允许的最多连接数,理论上每台nginx服务器的最大连接数为。worker_processes*worker_connections } http { include
    /etc/nginx/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"'; #定义日志格式

    #1.$remote_addr :访问ip,不一定是真实的,可能是代理服务器ip;

    假设用户的 IP 为(A),分别经过两个代理服务器(B,C),最后到达 Web 服务器,那么$remote_addr就是C,$http_x-forwarded-for 就是 A,B。

    #2.$remote_user :客户端用户名称;

    #3.$time_local :访问时间与时区;

    #4.$request :url与http协议;(get还是post)

    #5.$status :请求状态;

    #6.$body_bytes_sent 发送给客户端的文件内容大小;

    #7.$http_referer :从哪个页面链接访问过来的;

    #8.$http_user_agent :客户端浏览器的相关信息

    #9.$http_x_forwarded_for :真实的客户端ip地址


    access_log
    /var/log/nginx/access.log main; #访问日志路径 sendfile on;
    #sendfile指令指定 nginx 是否调用sendfile 函数(zero copy 方式)来输出文件,对于普通应用,必须设为on。如果用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络IO处理速度,降低系统uptime。 #tcp_nopush on; #此选项允许或禁止使用socke的TCP_CORK的选项,此选项仅在使用sendfile的时候使用 keepalive_timeout
    65; #keepalive超时时间。 #gzip on; #开启gzip压缩输出 include /etc/nginx/conf.d/*.conf; }
    server {
        listen       8090;
        server_name  localhost;
    
        #charset koi8-r;    #编码格式,若网页格式与此不同,将被自动转码
        #access_log  /var/log/nginx/host.access.log  main;


        location / {     #对url进行匹配
            root   /usr/share/nginx/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   /usr/share/nginx/html;
        }
    
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ .php$ {                 #url以.php结尾的自动转向127.0.0.1
        #    proxy_pass   http://127.0.0.1;
        #}
    
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000          #php请求转交给fastcgi处理
        #
        #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     #禁止访问.ht页面
        # concurs with nginx's one
        #
        #location ~ /.ht {
        #    deny  all;
        #}
    }

    参考http://blog.csdn.net/hzsunshine/article/details/63687054

    http://blog.csdn.net/tjcyjd/article/details/50695922

    https://www.cnblogs.com/huaxingtianxia/p/6369089.html

  • 相关阅读:
    HDU 1124 Factorial
    hdu 1690 Bus System
    hdu 1113 Word Amalgamation
    POJ 2482 Stars in Your Window
    hdu 1385 ZOJ 1456 Minimum Transport Cost(经典floyd)
    hdu 1907 John
    VMware 虚拟机 安装 UBuntu 9.10 命令模式转换成窗口模试
    #pragma CODE_SEG __NEAR_SEG NON_BANKED详解
    Ubuntu 下Hadoop 伪分布式 hadoop0.20.2.tar.gz 的安装
    文件拷贝代码以及疑问
  • 原文地址:https://www.cnblogs.com/fanren224/p/8469430.html
Copyright © 2020-2023  润新知