nginxの設定ファイルのメモ

openresty-1.11.2.2 Linux version 4.4.30-32.54.amzn1.x86_64

APIで高速化するために設定ファイルをごにょごにょ。 一旦こんな感じになった。 もっとこうしたらいいとか、 ここどうなってるのとかあればツッコミが欲しい。

他にもカーネルパラメーターとかちょっといじった。

どんなことしたか、別の機会に書こう!

nginx.conf

user  nginx;
worker_processes  auto;
worker_rlimit_nofile 65536;
pid /var/run/nginx.pid;

events {
    worker_connections 65536;
    #worker_connections 1024;
    multi_accept on;
    #accept_mutex off;
    use epoll;
}


http {
    include       mime.types;

    server_tokens off;
    client_header_timeout  3m;
    client_body_timeout    3m;
    send_timeout           3m;

    sendfile on;
    sendfile_max_chunk 512k;

    tcp_nopush on;
    tcp_nodelay on;

    access_log off;
    error_log off;

    open_file_cache max=1000 inactive=20s;
    open_file_cache_valid    30s;
    open_file_cache_min_uses 5;
    open_file_cache_errors   off;

    keepalive_requests 1000;
    keepalive_timeout 120;

    proxy_headers_hash_max_size 1024;
    proxy_headers_hash_bucket_size 256;

    log_format  main_ext  '$remote_addr - $remote_user [$time_local] "$request" '
                          '$status $body_bytes_sent "$http_referer" '
                          '"$http_user_agent" "$http_x_forwarded_for" '
                          '"$host" sn="$server_name" '
                          'rt=$request_time '
                          'ua="$upstream_addr" us="$upstream_status" '
                          'ut="$upstream_response_time" ul="$upstream_response_length" '
                          'cs=$upstream_cache_status' ;

    include /usr/local/openresty/nginx/conf/site-enable/*.conf;
}

site-enable/hoge.conf

upstream hoge {
    server unix:/var/run/circus/hoge.sock;
    keepalive 1000;
}

server {
    listen 80 default_server;

    server_name hoge.com;

    gzip on;
    gzip_http_version 1.0;
    gzip_comp_level  6;
    gzip_types       application/json;
    gzip_vary on;
    gzip_proxied any;
    gzip_buffers 16 8k;

    access_log logs/hoge.access.log main_ext buffer=32k;
    error_log  logs/hoge.error.log warn;

    # health check
    location = /hoge {
       access_log off;
       empty_gif;
       break;
    }

    location / {
      proxy_pass http://hoge;
      proxy_http_version 1.1;
      proxy_set_header Host $host;
      proxy_set_header X-Forwarded-Host $host;
      proxy_set_header Connection "";
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $remote_addr;
      proxy_set_header X-Forwarded-Host $host;
    }

}