Nginx配置文件分析

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

}
相關文章
相關標籤/搜索