美文网首页
nigx转发配置

nigx转发配置

作者: KingdomCoder | 来源:发表于2017-08-22 20:52 被阅读0次
    server {
          # nigx 启动端口也是监听端口
            listen       8080;
          #nigx 监听地址,可配置多个空格隔开
            server_name  127.0.0.1 192.168.191.1 ;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
            # 实际转发配置
            location / {
            #项目地址 内部转发地址
                    proxy_pass http://192.168.191.1:8084/;
                    proxy_redirect              off;
                    proxy_set_header Host  $host:$server_port;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For     
                    $proxy_add_x_forwarded_for;
                    client_max_body_size 100m;
                    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 1024k;
                    proxy_ignore_client_abort on;
            }   
            #项目地址 内部转发地址,检测路径party,检测到转发至  http://127.0.0.1:8089/party/
            location ^~ /party/ {
                    proxy_pass http://127.0.0.1:8089/party/;
                    proxy_redirect              off;
                    proxy_set_header Host $host:$server_port;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header REMOTE-HOST $remote_addr;
                    proxy_set_header X-Forwarded-For 
                   $proxy_add_x_forwarded_for;
                    client_max_body_size 100m;
                    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 1024k;
                    proxy_ignore_client_abort on;
            }
           location ^~ /community/ {
                   #项目地址 内部转发地址
                    proxy_pass http://127.0.0.1:8083/community/;
                    proxy_redirect              off;
                    proxy_set_header Host 183.131.19.165:58080;
                    proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header REMOTE-HOST $remote_addr;
                    proxy_set_header X-Forwarded-For 
                    $proxy_add_x_forwarded_for;
                    client_max_body_size 100m;
                    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 1024k;
                    proxy_ignore_client_abort on;
            } 
            #文件转发      
             location  ~* \.(apk|gif|jpg|jpeg|png|bmp|doc|docx|ppt|pptx|pdf|xls|xlsx)$ {
                root /usr/local/cci/files/;
                expires 10d;
                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;
                proxy_ignore_client_abort on;
             }
           
        }
       server {
           listen       8090;
            server_name  127.0.0.1 192.168.191.1;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
            
           location / {
                    proxy_pass http://192.168.191.1:8084/;
                    proxy_redirect              off;
                    proxy_set_header Host $host:$server_port;
                   proxy_set_header X-Real-IP $remote_addr;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    client_max_body_size 100m;
                    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;
                    proxy_ignore_client_abort on;
            }       
             location  ~* \.(apk|gif|jpg|jpeg|png|bmp|doc|docx|ppt|pptx|pdf|xls|xlsx)$ {
                root /usr/local/cci/files/;
                expires 10d;
                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;
                proxy_ignore_client_abort on;
             }
           
        }
    
    微信公众号欢迎关注.jpg

    相关文章

      网友评论

          本文标题:nigx转发配置

          本文链接:https://www.haomeiwen.com/subject/qmqrdxtx.html