Skip to content
Margirier Laurent edited this page Jun 22, 2015 · 4 revisions

nginx

Nginx has a crucial role to play.

Nginx will be hosted on a dedicated server based at Paris. I have it for 3years and it never went down. It will log every query, including the body content. I want to be able to recreate the full elasticsearch index if I need to, from the logs. The query will then be forwarded to one of my local servers. I'm not sure about the best strategy yet, I'll write more about it later.

Here are my notes about the configuration.

  • disabling logs doesn't impact really much
  • activating gzip=1 or even gzip=9 doesn't impact much
  • tcp_nodelay on; sendfile on; tcp_nopush on; don't impact much
log_format foul_machine_format '$status\t$time_local\t$msec\t$remote_addr\t'
                               '$http_x_foul_token\t$http_cookie\t'
                               '"$request"\t"$http_user_agent"\t\t'
                               '$request_body';
server {
    listen 3010;
    access_log /usr/local/var/log/nginx/foul_server.access.log foul_machine_format buffer=1024k flush=1m;
    # open_log_file_cache max=100000;

    #tcp_nodelay on;
    #sendfile on;
    #tcp_nopush on;


    root /www;
    error_page  405     =200 $uri;
}

https://rtcamp.com/tutorials/linux/logrotate/

/usr/local/var/log/nginx/bin.*.log {
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        sharedscripts
        prerotate
                if [ -d /etc/logrotate.d/httpd-prerotate ]; then \
                        run-parts /etc/logrotate.d/httpd-prerotate; \
                fi; \
        endscript
        postrotate
                [ ! -f /usr/local/var/run/nginx.pid ] || kill -USR1 `cat /usr/local/var/run/nginx.pid`
        endscript
}

https://gist.github.com/michiel/1064640

    if ($request_method = 'OPTIONS') {
            add_header "Access-Control-Allow-Origin" $http_origin;
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;

            return 204;
    }
Clone this wiki locally