백엔드 개발 PHP 튜토리얼 Nginx 레코드 요청 배포 로그 설정

Nginx 레코드 요청 배포 로그 설정

Jul 29, 2016 am 08:58 AM
html http request time

로그인 후 복사
nginx는 요청을 받은 후 백엔드 WEB 서비스 클러스터에 요청을 배포해야 합니다.

여기서 분석할 배포 로그를 기록해야 합니다. 백엔드 각 웹 서버에서 처리한 요청 수

<pre name="code" class="python">http {
log_format  main  
  ' $remote_user [$time_local]  $http_x_Forwarded_for $remote_addr  $request '
 '$http_x_forwarded_for '                     
 '$upstream_addr '                      
 'ups_resp_time: $upstream_response_time '                      
 'request_time: $request_time';

access_log  logs/access.log  main;

server{}
...
}
로그인 후 복사
로그에 표시되는 정보는 다음과 같습니다.
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.010 request_time: 0.011
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.16:8188 ups_resp_time: 0.006 request_time: 0.006
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.013 request_time: 0.013
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.17:8188 ups_resp_time: 0.003 request_time: 0.003
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.18:8188 ups_resp_time: 0.004 request_time: 0.004
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.012 request_time: 0.013
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.18:8188 ups_resp_time: 0.005 request_time: 0.005
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.16:8188 ups_resp_time: 0.011 request_time: 0.011
 - [31/May/2013:00:01:03 -0700]  - xxx.ip.addr.xxx  GET /portal/index.html HTTP/1.1 - 192.168.100.15:8188 ups_resp_time: 0.447 request_time: 0.759
로그인 후 복사

모든 구성 파일 nginx.conf.
# greatwqs@163.com Install on 2012-08-11 linux
# user  devwqs;

# 2 intel(R) xeon(R) CPU
worker_processes  4;

worker_cpu_affinity 00000001 00000010 00000100 00001000;

# error_log  logs/error.log;
# error_log  logs/error.log  notice;
error_log   logs/error.log  error;

pid        logs/nginx.pid;

# allow openning file nums
worker_rlimit_nofile 25600;

events {
    # linux 2.6 upper version.
    use epoll;
    worker_connections  51200;
}

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"'
    #                   '"$upstream_addr"' '"$upstream_response_time"';
    log_format  main  ' $remote_user [$time_local]  $http_x_Forwarded_for $remote_addr  $request '
                      '$http_x_forwarded_for '
                      '$upstream_addr '
                      'ups_resp_time: $upstream_response_time '
                      'request_time: $request_time';

    access_log  logs/access.log  main;

    sendfile                     on;
    # tcp_nopush                 on;
                                 
    keepalive_requests           200;
    keepalive_timeout            20;
    gzip  on;                    
    client_body_buffer_size      128k;
    client_body_timeout          60s;
    client_max_body_size         10m;
    # proxy_buffer_size          8k;
    # proxy_busy_buffers_size    64k;
    proxy_temp_file_write_size   64k;

    # portal-cluster
    upstream portal-cluster {
        # http://192.168.100.15:8188/portal/
        server 192.168.100.15:8188 weight=5 max_fails=5 fail_timeout=30s;

        # http://192.168.100.16:8188/portal/
        server 192.168.100.16:8188 weight=5 max_fails=5 fail_timeout=30s;
        
        # http://192.168.100.17:8188/portal/
        server 192.168.100.17:8188 weight=5 max_fails=5 fail_timeout=30s;
        
        # http://192.168.100.18:8188/portal/
        server 192.168.100.18:8188 weight=5 max_fails=5 fail_timeout=30s;
    }

    # manage-cluster
    upstream manage-cluster {
        # http://192.168.100.25:8189/manage/
        server 192.168.100.25:8189 weight=4 max_fails=5 fail_timeout=30s;

        # http://192.168.100.26:8189/manage/
        server 192.168.100.26:8189 weight=6 max_fails=5 fail_timeout=30s;
    }

    # External Internet.
    server {
        listen       80;
        server_name  www.huaxixiang.com;
        access_log   logs/host.access.log  main;

        location /portal/ {
            # root   html;
            # index  index.html index.htm;
            # nginx http header send to tomcat app.
            # proxy_set_header Host  $host;
            # proxy_set_header X-Forwarded-For  $remote_addr;
            proxy_set_header Host $host;
            proxy_set_header X-Real-Ip $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;

            proxy_pass http://portal-cluster;
        }

        # nginx status
        location /nginx_status {
            # copied from http://blog.kovyrin.net/2006/04/29/monitoring-nginx-with-rrdtool/
            stub_status  on;
            access_log   off;
            allow        192.168.100.100;
            #deny all;
        }

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

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

    # External Internet.
    server {
        listen       80;
        server_name  manage.huaxixiang.com;

        access_log  logs/host.access.log  main;

        location /manage/ {
            proxy_pass http://manage-cluster;
        }

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

        error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}
로그인 후 복사

nginx 상태 보기:

Nginx 记录请求分发日志设置

위 내용은 내용의 측면을 포함하여 Nginx 레코드 요청 배포 로그 설정을 소개한 내용이 PHP 튜토리얼에 관심이 있는 친구들에게 도움이 되기를 바랍니다.

본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.

핫 AI 도구

Undresser.AI Undress

Undresser.AI Undress

사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover

AI Clothes Remover

사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool

Undress AI Tool

무료로 이미지를 벗다

Clothoff.io

Clothoff.io

AI 옷 제거제

AI Hentai Generator

AI Hentai Generator

AI Hentai를 무료로 생성하십시오.

인기 기사

R.E.P.O. 에너지 결정과 그들이하는 일 (노란색 크리스탈)
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 최고의 그래픽 설정
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. 아무도들을 수없는 경우 오디오를 수정하는 방법
4 몇 주 전 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25 : Myrise에서 모든 것을 잠금 해제하는 방법
1 몇 달 전 By 尊渡假赌尊渡假赌尊渡假赌

뜨거운 도구

메모장++7.3.1

메모장++7.3.1

사용하기 쉬운 무료 코드 편집기

SublimeText3 중국어 버전

SublimeText3 중국어 버전

중국어 버전, 사용하기 매우 쉽습니다.

스튜디오 13.0.1 보내기

스튜디오 13.0.1 보내기

강력한 PHP 통합 개발 환경

드림위버 CS6

드림위버 CS6

시각적 웹 개발 도구

SublimeText3 Mac 버전

SublimeText3 Mac 버전

신 수준의 코드 편집 소프트웨어(SublimeText3)

HTML의 테이블 테두리 HTML의 테이블 테두리 Sep 04, 2024 pm 04:49 PM

HTML의 테이블 테두리 안내. 여기에서는 HTML의 테이블 테두리 예제를 사용하여 테이블 테두리를 정의하는 여러 가지 방법을 논의합니다.

HTML 여백-왼쪽 HTML 여백-왼쪽 Sep 04, 2024 pm 04:48 PM

HTML 여백-왼쪽 안내. 여기에서는 HTML margin-left에 대한 간략한 개요와 코드 구현과 함께 예제를 논의합니다.

HTML의 중첩 테이블 HTML의 중첩 테이블 Sep 04, 2024 pm 04:49 PM

HTML의 Nested Table에 대한 안내입니다. 여기에서는 각 예와 함께 테이블 내에 테이블을 만드는 방법을 설명합니다.

HTML 테이블 레이아웃 HTML 테이블 레이아웃 Sep 04, 2024 pm 04:54 PM

HTML 테이블 레이아웃 안내. 여기에서는 HTML 테이블 레이아웃의 값에 대해 예제 및 출력 n 세부 사항과 함께 논의합니다.

HTML 입력 자리 표시자 HTML 입력 자리 표시자 Sep 04, 2024 pm 04:54 PM

HTML 입력 자리 표시자 안내. 여기서는 코드 및 출력과 함께 HTML 입력 자리 표시자의 예를 논의합니다.

HTML 정렬 목록 HTML 정렬 목록 Sep 04, 2024 pm 04:43 PM

HTML 순서 목록에 대한 안내입니다. 여기서는 HTML Ordered 목록 및 유형에 대한 소개와 각각의 예에 대해서도 설명합니다.

HTML에서 텍스트 이동 HTML에서 텍스트 이동 Sep 04, 2024 pm 04:45 PM

HTML에서 텍스트 이동 안내. 여기서는 Marquee 태그가 구문과 함께 작동하는 방식과 구현할 예제에 대해 소개합니다.

HTML 온클릭 버튼 HTML 온클릭 버튼 Sep 04, 2024 pm 04:49 PM

HTML onclick 버튼에 대한 안내입니다. 여기에서는 각각의 소개, 작업, 예제 및 다양한 이벤트의 onclick 이벤트에 대해 설명합니다.

See all articles