您的位置:首页 > 运维架构 > Nginx

nginx配置笔记

2016-07-05 14:50 585 查看
#user  nginx nginx; #无用户注释掉

worker_processes 4;

error_log  /usr/local/nginx/logs/nginx_error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 51200;

events

        {

                use epoll;

                worker_connections 51200;

        }

http

        {

                include       mime.types;

                default_type  application/octet-stream;

                charset  utf-8;

                server_names_hash_bucket_size 128;

                client_header_buffer_size 32k;

                large_client_header_buffers 4 32k;

                client_max_body_size 8m;

                sendfile on;

                tcp_nopush     on;

                keepalive_timeout 60;

                tcp_nodelay on;

                fastcgi_connect_timeout 300;

                fastcgi_send_timeout 300;

                fastcgi_read_timeout 300;

                fastcgi_buffer_size 64k;

                fastcgi_buffers 4 64k;

                fastcgi_busy_buffers_size 128k;

                fastcgi_temp_file_write_size 256k;

                proxy_connect_timeout 600;

                proxy_read_timeout    600;

                proxy_send_timeout    600;

                proxy_buffer_size     32k;

                proxy_buffers         4 32k;

                proxy_busy_buffers_size  64k;

#               proxy_temp_file_write_size  1024m;

                gzip on;

                gzip_min_length  1k;

                gzip_buffers     4 16k;

                gzip_http_version 1.1;

                gzip_comp_level 6;

                gzip_types       text/plain application/x-javascript text/css application/xml;

                gzip_vary on;

                #limit_zone  crawler  $binary_remote_addr  10m;

include vhost/*.conf;
#include deny_ip.conf;
}

vhost/authsys.conf

            log_format  authsys  '$remote_addr - $remote_user [$time_local] "$request" '

             '$status $body_bytes_sent "$http_referer" '

             '"$http_user_agent" $http_x_forwarded_for';

server

     {

            listen            1181;

            server_name   192.168.168.112:8080; #若为域名指向域名
if ($request_uri ~ ".*/.svn/.*")
{
return 404;
}

            location / {

            proxy_pass http://192.168.168.112:8080/;#若为域名指向域名
            proxy_set_header   Host  $host;

            proxy_set_header   X-Real-IP $remote_addr;

            proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

 

                access_log  /usr/local/nginx/logs/authsys.log authsys;

 

}

 }

如需负载均衡配置如下 :vhost/upstream.conf

ip指向,解决session共享问题

upstream xxcom

 {

     ip_hash;

     server 192.168.0.12:80 max_fails=2 fail_timeout=5s;

 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: