sat
sat

Reputation: 21

Nginx writes nothing in access.log

I'm developing a Rails App on Nginx with Unicorn. When I start Nginx with Capistrano, but access.log cannot written.

I have changed permission and user of log directory and files too, but it didn't work for me. Can anybody help me?

My nginx.conf is like this

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
  worker_connections  1024;
}

http {
  include       /etc/nginx/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  /var/log/nginx/access.log  main;
  sendfile        on;
  keepalive_timeout  65;

  upstream unicorn {
    server unix:/tmp/unicorn.sock fail_timeout=0;
  }

  server {
    listen       80 default_server;
    server_name  _;

    location ~ ^/assets/ {
      root /home/vagrant/xxx/public;
    }

    location / {
      proxy_pass http://unicorn;
    }
  }
}

and I already changed user from 'nginx' to 'vagrant'. ('vagrant' is ssh user for server)

directory:

drwx------  2 vagrant vagrant   4096 Nov 20 18:53 nginx

log files:

-rw-r--r-- 1 nginx   nginx   0 Nov 20 18:53 access.log
-rw-r--r-- 1 vagrant vagrant 0 Nov 20 18:53 error.log

unicorn.rb (located in rails app)

listen "/tmp/unicorn.sock"
worker_processes 2 # this should be >= nr_cpus
working_directory "/home/vagrant/xxx/current"
pid "/home/vagrant/xxx/shared/tmp/pids/unicorn.pid"
stderr_path "/home/vagrant/xxx/shared/log/unicorn.log"
stdout_path "/home/vagrant/xxx/shared/log/unicorn.log"

before_exec do |server|
  ENV['BUNDLE_GEMFILE'] = "/home/vagrant/xxx/current/Gemfile"
end

Upvotes: 1

Views: 1934

Answers (1)

sat
sat

Reputation: 21

Afterwhile, I have noticed some mistakes in nginx.conf.

  1. user should be same as server user.
  2. wrong URL access to served port.

Upvotes: 1

Related Questions