nginx配置详解_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > nginx配置详解

nginx配置详解

 2016/5/27 0:32:30  lxlcx201  程序员俱乐部  我要评论(0)
  • 摘要:#pid/var/run/nginx.pid;worker_processes8;worker_rlimit_nofile100000;events{worker_connections2048;multi_accepton;useepoll;}http{#log_formatmain'$remote_addr
  • 标签:详解 配置 Nginx
#pid /var/run/nginx.pid; 
worker_processes 8; 
worker_rlimit_nofile 100000; 
events { 
worker_connections 2048; 
multi_accept on; 
use epoll; 



http {
 
   # 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  /data/logs/nginx/access.log;

        server_tokens off; 
        sendfile on; 
        tcp_nopush on; 
        tcp_nodelay on; 
        access_log on; 
        error_log /data/logs/nginx/error.log; 
        keepalive_timeout 300; 
        client_header_timeout 30; 
        client_body_buffer_size 256k; #缓冲区代理缓冲用户端请求的最大字节数,
        client_body_timeout 30;
        client_max_body_size 20m; 
        reset_timedout_connection on; 
        send_timeout 10; 
        limit_conn_zone $binary_remote_addr zone=addr:5m; 
        limit_conn addr 100; 
        include mime.types; 
        default_type text/html; 
        charset UTF-8; 
        gzip on; 
        gzip_disable "msie6"; 
        gzip_proxied any; 
        gzip_min_length 2000; 
        gzip_comp_level 5; 
        gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 
        open_file_cache max=100000 inactive=20s; 
        open_file_cache_valid 30s; 
        open_file_cache_min_uses 2; 
        open_file_cache_errors on; 
#       include /etc/nginx/conf.d/*.conf; 
#       include /etc/nginx/sites-enabled/*;
        proxy_buffer_size 32k;
        proxy_buffers 32 256k;
        proxy_busy_buffers_size 1024k;


        server {
                        listen  80  ;
                        server_name  teapp.xxx.com;
                        location / {
                                proxy_pass http://ip:3655;
                            }
                }
        server {
                        listen  80  ;
                        server_name  yryz.com www.xxxx.com;
                        charset utf-8;

#                       location / {
#                       root /data/web1;
#                         index index.html;
#                        }
                        location /upload/ {
                                #proxy_pass http://ip:8080/lcx;

                                proxy_pass http://ip:8080/lcx;
                                proxy_redirect default;
                        }




                        location /lcx/ {
                                proxy_pass http://127.0.0.1:8080;
                                proxy_redirect default;
                                proxy_set_header X-Real-IP $remote_addr;
                                #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
                                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                ##以下是一些反向代理的配置,可选。
                                proxy_set_header Host $host;
                                client_max_body_size 10m; #允许客户端请求的最大单文件字节数
                                client_body_buffer_size 256k; #缓冲区代理缓冲用户端请求的最大字节数,
                                proxy_connect_timeout 90; #nginx跟后端服务器连接超时时间(代理连接超时)
                                proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)
                                proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)
                                proxy_buffer_size 8k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
                                proxy_buffers 8 64k; #proxy_buffers缓冲区,网页平均在32k以下的设置
                                proxy_busy_buffers_size 256k; #高负荷下缓冲大小(proxy_buffers*2)
                                proxy_temp_file_write_size 128k;
                                ##设定缓存文件夹大小,大于这个值,将从upstream服务器传
                        }

                        location /lcx_web/ {
                                proxy_pass http://127.0.0.1:8082;
                                proxy_redirect default;
                                proxy_set_header X-Real-IP $remote_addr;
                                #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
                                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                ##以下是一些反向代理的配置,可选。
                                proxy_set_header Host $host;
                                client_max_body_size 10m; #允许客户端请求的最大单文件字节数
                                client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数,
                                proxy_connect_timeout 90; #nginx跟后端服务器连接超时时间(代理连接超时)
                                proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)
                                proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)
                                proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
                                proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的设置
                                proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2)
                                proxy_temp_file_write_size 64k;
                                ##设定缓存文件夹大小,大于这个值,将从upstream服务器传
                         }

                        location /lcx_manage/ {
                                proxy_pass http://127.0.0.1:8083;
                                proxy_redirect default;
                                proxy_set_header X-Real-IP $remote_addr;
                                #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
                                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                               ##以下是一些反向代理的配置,可选。
                                proxy_set_header Host $host;
                                client_max_body_size 10m; #允许客户端请求的最大单文件字节数
                                client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数,
                                proxy_connect_timeout 90; #nginx跟后端服务器连接超时时间(代理连接超时)
                                proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)
                                proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)
                                proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
                                proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的设置
                                proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2)
                                proxy_temp_file_write_size 64k;
                                #
                        }

                        location /file {
                                proxy_pass http://ip:port;
                                proxy_redirect default;
                                proxy_set_header X-Real-IP $remote_addr;
                                #后端的Web服务器可以通过X-Forwarded-For获取用户真实IP
                                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                                ##以下是一些反向代理的配置,可选。
                                proxy_set_header Host $host;
                                client_max_body_size 10m; #允许客户端请求的最大单文件字节数
                                client_body_buffer_size 128k; #缓冲区代理缓冲用户端请求的最大字节数,
                                proxy_connect_timeout 90; #nginx跟后端服务器连接超时时间(代理连接超时)
                                proxy_send_timeout 90; #后端服务器数据回传时间(代理发送超时)
                                proxy_read_timeout 90; #连接成功后,后端服务器响应时间(代理接收超时)
                                proxy_buffer_size 4k; #设置代理服务器(nginx)保存用户头信息的缓冲区大小
                                proxy_buffers 4 32k; #proxy_buffers缓冲区,网页平均在32k以下的设置
                                proxy_busy_buffers_size 64k; #高负荷下缓冲大小(proxy_buffers*2)
                                proxy_temp_file_write_size 64k;
                                ##设定缓存文件夹大小,大于这个值,将从upstream服务器传
                                                                                                                                                                                                    
                         }

#                       location /upload/lcx/ {
#                               proxy_pass http://lcx:port/;
#                                proxy_redirect off;
#                                proxy_set_header X-Real-IP $remote_addr;
#                               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                                proxy_set_header Host $host;
#                              client_max_body_size 10m;
#                              client_body_buffer_size 128k;
#                              proxy_connect_timeout 90;
#                               proxy_send_timeout 90;
#                               proxy_read_timeout 90;
#                               proxy_buffer_size 4k;
#                               proxy_buffers 4 32k;
#                               proxy_busy_buffers_size 64k;
#                               proxy_temp_file_write_size 64k;

#                       }

                location / {
                                proxy_pass    http://127.0.0.1:8082/lcx_web/f/index;
                        }


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




}



java交流群 :216396734
发表评论
用户名: 匿名