Configuration problem whit ngingx and unicorn

Hello again:

I am working to configure a nginx-unicorn server but when I am finish
to configuring that server and try to enter to de web site, the welcome
to nginx default page open, and not my web site, this is my
configuration files:
nginx

redmine:
upstream redmine {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a
single worker for timing out).
# server unix:/tmp/myapplication.sock fail_timeout=0;
server unix:/var/www/redmine/tmp/sockets/unicorn.sock
fail_timeout=0;
}

server {
listen 80; # default;
client_max_body_size 4G;
server_name redmine.unicorn.com.ve;
root /var/www/redmine/public;
keepalive_timeout 5;

location / {
access_log off;

include proxy_params;
proxy_redirect off;

if (-f $request_filename) {
  access_log          off;
  expires             max;
  break;
}

if (-f $request_filename.html) {
  rewrite (.*) $1.html break;
}

access_log off;

include proxy_params;
proxy_redirect off;

if (-f $request_filename) {
  access_log          off;
  expires             max;
  break;
}

if (-f $request_filename.html) {
  rewrite (.*) $1.html break;
}

if (!-f $request_filename) {
  proxy_pass          http://redmine;
  break;
}

}

     # Rails error pages
            error_page 500 502 503 504 /500.html;
            location = /500.html {
            root /home/service/apps/redmine/public;
                            }

}

#UNICORNS

redmine.rb
worker_processes 1
working_directory “/var/www/redmine/public”

This loads the application in the master process before forking

worker processes

Read more about it here:

class Unicorn::Configurator

preload_app true

timeout 60

This is where we specify the socket.

We will point the upstream Nginx module to this socket later on

listen “/var/www/redmine/tmp/sockets/unicorn.sock”, :backlog => 64
listen 8080, :tcp_nopush => true

pid “/var/www/redmine/tmp/pids/unicorn.pid”

Set the path of the log files inside the log folder of the testapp

stderr_path “/var/www/redmine/log/unicorn.stderr.log”
stdout_path “/var/www/redmine/log/unicorn.stdout.log”

before_fork do |server, worker|

This option works in together with preload_app true setting

What is does is prevent the master process from holding

the database connection

defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end

and the log file
I, [2013-07-11T11:14:56.151485 #5077] INFO – : Refreshing Gem list
/var/lib/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:32:
warning: already initialized constant DEF_OPTIONS
/var/lib/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in
`block in require’: iconv will be deprecated in the future, use
String#encode instead.
I, [2013-07-11T11:15:09.579343 #5077] INFO – : unlinking existing
socket=/var/www/redmine/tmp/sockets/unicorn.sock
I, [2013-07-11T11:15:09.579724 #5077] INFO – : listening on
addr=/var/www/redmine/tmp/sockets/unicorn.sock fd=10
I, [2013-07-11T11:15:09.580282 #5077] INFO – : listening on
addr=0.0.0.0:8080 fd=11
I, [2013-07-11T11:15:09.585867 #5077] INFO – : master process ready
I, [2013-07-11T11:15:09.606967 #5086] INFO – : worker=0 ready

some times the log file say:

I, [2013-07-11T12:01:26.607025 #5518] INFO – : Refreshing Gem list
/var/lib/gems/1.9.1/gems/ruby-debug-ide19-0.4.12/lib/ruby-debug/command.rb:32:
warning: already initialized constant DEF_OPTIONS
/var/lib/gems/1.9.1/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:251:in
block in require': iconv will be deprecated in the future, use String#encode instead. I, [2013-07-11T12:01:40.023799 #5518] INFO -- : listening on addr=/var/www/redmine/tmp/sockets/unicorn.sock fd=10 E, [2013-07-11T12:01:40.024537 #5518] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use) E, [2013-07-11T12:01:40.024630 #5518] ERROR -- : retrying in 0.5 seconds (4 tries left) E, [2013-07-11T12:01:40.525005 #5518] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use) E, [2013-07-11T12:01:40.525160 #5518] ERROR -- : retrying in 0.5 seconds (3 tries left) E, [2013-07-11T12:01:41.025482 #5518] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use) E, [2013-07-11T12:01:41.025606 #5518] ERROR -- : retrying in 0.5 seconds (2 tries left) E, [2013-07-11T12:01:41.526000 #5518] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use) E, [2013-07-11T12:01:41.526330 #5518] ERROR -- : retrying in 0.5 seconds (1 tries left) E, [2013-07-11T12:01:42.033350 #5518] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use) E, [2013-07-11T12:01:42.033491 #5518] ERROR -- : retrying in 0.5 seconds (0 tries left) E, [2013-07-11T12:01:42.533870 #5518] ERROR -- : adding listener failed addr=0.0.0.0:8080 (in use) /var/lib/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:147:in initialize’: Address already in use - bind(2) (Errno::EADDRINUSE)
from
/var/lib/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:147:in
new' from /var/lib/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/socket_helper.rb:147:in bind_listen’
from
/var/lib/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:229:in
listen' from /var/lib/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:773:in block in bind_new_listeners!’
from
/var/lib/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:773:in
each' from /var/lib/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:773:in bind_new_listeners!’
from
/var/lib/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn/http_server.rb:141:in
start' from /var/lib/gems/1.9.1/gems/unicorn-4.6.3/bin/unicorn_rails:209:in <top (required)>’
from /usr/local/bin/unicorn_rails:19:in load' from /usr/local/bin/unicorn_rails:19:in

Please help me.

After many hours breaking my head, i am realize that my mistake was
not create the link symbolic in nginx

ln -s /etc/nginx/sites-available/redmine
/etc/nginx/sites-enabled/redmine

:slight_smile: :()