Welcome! Log In Create A New Profile

Advanced

Problem with unicorn: "upstream" directive is not allowed

Posted by atmosx 
Problem with unicorn: "upstream" directive is not allowed
June 25, 2012 01:43PM
Hello,

I'm new to nginx. I used to use lighttpd for simple tasks like setting up static websites on the local network for un. Now I'm setting up an "octopress" blog with unicorn. Everything works except the last touch which is "nginx".

Here is my unicorn.rb config for the rails app:

----
sites-enabled # cat /home/user/repos/oxyblog/unicorn.rb
# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
# documentation.
worker_processes 4
# Help ensure your application will always spawn in the symlinked
# "current" directory that Capistrano sets up.
working_directory "/home/user/repos/oxyblog/"
# listen on both a Unix domain socket and a TCP port,
# we use a shorter backlog for quicker failover when busy
listen "/tmp/oxyblog.sock", :backlog => 64
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 30
# feel free to point this anywhere accessible on the filesystem
user 'user', 'group'
shared_path = '/home/user/repos/oxyblog/shared'
pid "#{shared_path}/pids/unicorn.pid"
stderr_path "#{shared_path}/log/unicorn.stderr.log"
stdout_path "#{shared_path}/log/unicorn.stdout.log"
----

Here is my nginx sites-enable/oxyblog config:

------
# as we are going to use Unicorn as the application server
# we are not going to use common sockets
# but Unix sockets for faster communication
upstream oxyblog {
# 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).

# for UNIX domain socket setups:
server unix:/tmp/oxyblog.sock fail_timeout=0;
}

server {
# if you're running multiple servers, instead of "default" you should
# put your main domain name here
listen 80 oxygen.mine.nu;
# you could put a list of other domain names this application answers
server_name comodino;

root /home/user/repos/oxyblog/public;
access_log /var/log/nginx/oxyblog_access.log;
rewrite_log on;

location / {
#all requests are sent to the UNIX socket
proxy_pass http://oxyblog;
proxy_redirect off;

proxy_set_header Host $host:$proxy_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

client_max_body_size 10m;
client_body_buffer_size 128k;

proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;

proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
}

# if the request is for a static resource, nginx should serve it directly
# and add a far future expires header to it, making the browser
# cache the resource and navigate faster over the website
location ~ ^/(images|javascripts|stylesheets|system)/ {
root /home/user/repos/oxyblog/public;
expires max;
break;
}
------


I'm on Gentoo linux and the error I get when I nginx is the following:


comodino sites-enabled # /etc/init.d/nginx start
* Checking nginx' configuration ...
nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/sites-enabled/oxyblog:4
nginx: configuration file /etc/nginx/nginx.conf test failed
nginx: [emerg] "upstream" directive is not allowed here in /etc/nginx/sites-enabled/oxyblog:4
nginx: configuration file /etc/nginx/nginx.conf test failed
* failed, please correct errors above [ !! ]
* ERROR: nginx failed to start


I double checked my config, but I can't find anything related to the error.. is there any compile issue that I missed or it's a cofiguration error?

Any help/hint would be good.

Thanks & best regards
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 201
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready