---
title: "nginx配置"
author: "myangle89"
date: "2013-02-20T11:22:14Z"
tags: []
categories: ["互联网"]
slug: "nginx"
draft: false
lastmod: "2013-02-20T11:22:14Z"
id: 1808294
url: "https://myangle89.iteye.com/blog/1808294"
---

#user  nobody;

worker\_processes  1;

 

#error\_log  logs/error.log;

#error\_log  logs/error.log  notice;

#error\_log  logs/error.log  info;

 

#pid        logs/nginx.pid;

 

 

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

 

    upstream localhost {

server localhost:10001 weight=1 max\_fails=2 fail\_timeout=30s;

server localhost:10002 weight=1 max\_fails=2 fail\_timeout=30s;

#ip\_hash;

    }

 

    server {

        listen       800;

        server\_name  localhost;

 

        #charset koi8-r;

 

        #access\_log  logs/host.access.log  main;

 

#location ~* software/(.\*).\*\\.(jpg|rar)

        #{

        #    expires 21d;

        #    root d:/temp/;

        #    access\_log d:/temp/soft.3g.cn\_nginx\_s3gd-205.log;

        #    proxy\_store on;

        #    proxy\_store\_access user:rw group:rw all:rw;

        #    proxy\_temp\_path            d:/temp/;

        #    proxy\_redirect          off;

 

        #    proxy\_set\_header        Host 112.25.10.140;

        #    proxy\_set\_header        X-Real-IP $remote\_addr;

        #    proxy\_set\_header        X-Forwarded-For $proxy\_add\_x\_forwarded\_for;

        #    client\_max\_body\_size    10m;

        #    client\_body\_buffer\_size 1280k;

        #    proxy\_connect\_timeout   900;

        #    proxy\_send\_timeout      900;

        #    proxy\_read\_timeout      900;

        #    proxy\_buffer\_size       40k;

        #    proxy\_buffers           40 320k;

        #    proxy\_busy\_buffers\_size 640k;

        #    proxy\_temp\_file\_write\_size 640k;

        #    if ( !-e $request\_filename)

        #    {

        #         proxy\_pass  http://112.25.10.140:80;

        #    }

        #}

 

        location / {

            root   html;

            index  index.html index.htm;

   proxy\_pass  http://localhost;

   proxy\_redirect  off;

   proxy\_set\_header  Host $host;

   proxy\_set\_header  X-Real-IP $remote\_addr;

   proxy\_set\_header  X-Forwarded-For $proxy\_add\_x\_forwarded\_for;

   client\_max\_body\_size  10m;

   client\_body\_buffer\_size  128k;

   proxy\_connect\_timeout  5s;

   proxy\_send\_timeout  30s;

   proxy\_read\_timeout  30s;

   proxy\_buffer\_size  4k;

   proxy\_buffers  4 32k;

   proxy\_busy\_buffers\_size  64k;

   proxy\_temp\_file\_write\_size  64k;

        }

 

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

    #    server\_name  localhost;

 

    #    ssl                  on;

    #    ssl\_certificate      cert.pem;

    #    ssl\_certificate\_key  cert.key;

 

    #    ssl\_session\_timeout  5m;

 

    #    ssl\_protocols  SSLv2 SSLv3 TLSv1;

    #    ssl\_ciphers  HIGH:!aNULL:!MD5;

    #    ssl\_prefer\_server\_ciphers   on;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

}