nginx配置参考2

来源:互联网 发布:js购物车数量加减合计 编辑:程序博客网 时间:2024/06/11 05:57
[root@172 conf]# cat nginx.conf

user  www;
worker_processes  4;
error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;
events {
    use epoll;
    worker_connections  35525;
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    #log日志全局格式
    log_format  access  '$http_x_forwarded_for - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$request_time"';

    server_tokens off;
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  45;

    #gzip  on;
    
    upstream epiao {
        #ip_hash;
        server  10.16.210.12:8080;
        server  10.16.210.13:8080;
        server  10.16.210.62:8080;
        server  10.16.210.63:8080;
        server  10.16.210.112:8080;
        server  10.16.210.113:8080;
        server  10.16.210.162:8080;
        server  10.16.210.163:8080;
                    }

    server {
        listen 80 default_server;
        server_name  lcaolhosts;
        location / {
            autoindex on;
            autoindex_exact_size on;
            autoindex_localtime on;
            add_header Access-Control-Allow-Origin *;
            expires 10s;
        }

        location /status {
                stub_status on;
                access_log off;
                allow 10.16.100.15;
                allow 127.0.0.1;
                deny all;


                         }
           }

    server {
        listen       80 ;
        server_name  www.test.com;

        #charset koi8-r;
        #后端日志
        access_log  logs/piaotest.access.log  access;

        location / {
                  proxy_redirect off;
                  proxy_set_header Host $host;
                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                  client_max_body_size 15m;
                  proxy_pass http://epiao;
                   }
                  error_page   500 502 503 504  /50x.html;

        location = /50x.html {
                  root   html;
                             }
            }

    server {
        listen       80 ;
        server_name  static.test.com;


        #charset koi8-r;
        #static静态日志
        access_log  logs/static.access.log  access;

        location / {
            root   html;
            index  index.html index.htm;
                   }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

upstream backend
               {
         server 172.16.230.200:9040;
               }
 #ssl认证
    server {
        listen 8081;
        server_name localhosts;
        #ssl on;
        #ssl_certificate  /app/nginx/conf/server.crt;
        #ssl_certificate_key /app/nginx/conf/server.key;
        #ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        #ssl_ciphers  HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM;
        #ssl_prefer_server_ciphers on;
        #ssl_session_cache shared:SSL:10m;

        location / {
                client_max_body_size 10m;
                proxy_buffering off;
                proxy_redirect http:// $scheme://;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_pass http://backendtest;
                   }

        location ~ .*\.(html|htm)$ {
                root /app/nginx/html/pontus;
                index  index.html index.htm;
                expires      1m;
        }

        location ~ .*\.(gif|jpg|jpeg|bmp|png|ico|txt|js|css)$ {
                root /app/nginx/html/pontus;
                index  index.html index.htm;
                expires      300d;                                                                       }


        }


}
0 0