nginx 방식 실현 및 관련 오류 해결 방법

참고: Nginx 역방향 에이전트 최적화 요점 proxybuffering
nginx 를 이용 하여 역방향 대 리 를 할 때 설정 파일 은 아래 설정 을 참고 할 수 있 습 니 다.
user  nginx;
worker_processes  2;

error_log  logs/error.log warn;
pid        logs/nginx.pid;
events {
    worker_connections  10240;
    multi_accept        on;
    use                 epoll;
}
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;
    tcp_nodelay        on;
    underscores_in_headers on;#off     header name      ,    ,         on   
    keepalive_timeout  240;
    server_tokens off; #     
    send_timeout 10m;
    client_header_buffer_size 256k;
    client_max_body_size 1000m;
    client_body_timeout 10m;
    client_header_timeout 10m;
    large_client_header_buffers 8 64k;
    client_body_buffer_size 20m;

    fastcgi_buffers 6 256k;
    fastcgi_buffer_size 1024k;
    fastcgi_busy_buffers_size 1024k;
    proxy_request_buffering off;
    proxy_buffering    off; #                  
    proxy_buffer_size  128k; #           
    proxy_buffers 100  128k;
    proxy_busy_buffers_size 128k;
	
	upstream NAME {
        server host:port;
    }
    upstream NAME_SSL {
        server host:443;
    }
	
    server {
        listen       80;
        server_name  a.example.com;
        charset utf8;
        ignore_invalid_headers off;
	error_page  404  403 =https://a.example.com/404.html;
	location / {
            include conf.d/deny_appid.conf; #location     
            proxy_pass http://NAME/;
            proxy_redirect  off;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Cookie $http_cookie;
            chunked_transfer_encoding  off;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
        }
    }
    server {
        listen       443 ssl;
        server_name  a.example.com;
        ignore_invalid_headers off;
        charset utf8;

        ssl_certificate      example.com.crt;
        ssl_certificate_key  example.com.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;
        error_page  404  403 =https://a.example.com/404.html;
        location / {
            include conf.d/deny_appid.conf;
            proxy_pass https://NAME_SSL/;
            proxy_ssl_session_reuse off;
            proxy_redirect  off;
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Cookie $http_cookie;
            chunked_transfer_encoding  off;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
        }
    }
}

nginx + tomcat 오류 보고: "upstream 응답 이 임시 파일 로 버퍼 링 됨" 
참조 링크:https://blog.51cto.com/11413817/1950467 
nginx 의 an upstream response is buffered to a temporary file 오류
client_header_buffer_size 256k; 
    32k  256k

nginx fastcgi_buffers to an upstream response is buffered to a temporary file
fastcgi_buffers 16 16k;
                   FastCGI   ,    ,    php           256k,      16 16k       ,    256k,   256k       fastcgi_temp      ,                  ,                ,                    php              ,                    256k          16 16k,  4 64k   64 4k,    ,            ,           32k,   4 64k    1 64k       ,     64 4k    8 4k       ,     16 16k     2 16k     ,           。 
 
//+++++++++++++++++++++++++++++++++++++++++
client_max_body_size 100m; #                
client_body_buffer_size 2048k; #                  ,
fastcgi_buffer_size 1024k; 
fastcgi_buffers 6 256k; 
fastcgi_busy_buffers_size 1024k; 

fastcgi_buffer  :fastcgi_buffer_size + the_number * is_size
fastcgi_buffers 256 4k; #  buffer   :4k + 256 * 4k = 1028k
         an upstream response is buffered to a temporary file  nginx+php-fpm   

php 502 문제 해결: recv () failed (104: Connection reset by peer) upstream 에서 응답 헤 더 를 읽 는 동안
참고:https://blog.csdn.net/donglynn/article/details/76759548 
nginx error: upstream prematurely closed connection while reading response header from upstream 
참고:https://www.cnblogs.com/xinpureZhu/p/6142183.html 
nginx access log 닫 기
access_log off;

nginx error_로그 로그 조정 단계:
error_log  logs/error.log info|notice|warn|error;

좋은 웹페이지 즐겨찾기