ruby p290p; nginx 1.0.;8 unicorn url redirect

danzel nginx-forum at nginx.us
Thu Oct 6 02:54:03 UTC 2011


Hi,

Sorry to bother you, I find this odd problem. When using ruby p180 +
nginx 1.0.8 + unicorn, the url redirection works perfectly but with ruby
p290, the page always redirects to the first entry on our vhost file.
Any inputs will be greatly appreciated. Thanks Guys!

Here is my entry on my vhost.conf:

server {
  listen      80;
  server_name games.example.com;
  rewrite ^(.*) http://www.example.com/games permanent;
}

my nginx.conf:

user www-data;
worker_processes  2;
worker_rlimit_nofile  30000;
daemon off;

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

events {
  worker_connections  2048;
}

http {
  include       /etc/nginx/mime.types;
  default_type  application/octet-stream;

  access_log	/mnt/log/nginx/access.log;

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;

  keepalive_timeout  65;

  gzip  on;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_types text/plain text/css application/json
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;
    gzip_vary on;
    gzip_buffers 16 8k;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

  server_names_hash_bucket_size 64;

  include /etc/nginx/conf.d/*.conf;
}

my unicorn.conf:

include /etc/nginx/conf.d/unicorn/upstream.conf;

# HTTP server
#
server {
  listen      80;
  server_name ip-10-138-105-254;
  log_format aws '$proxy_add_x_forwarded_for - $remote_user
[$time_local]  "$request" $status $body_bytes_sent "$http_referer"
"$http_user_agent"';
  access_log  /mnt/log/nginx/ip-10-138-105-254.access.log aws;
  root        /var/www/friendster-neutron/current/public;

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

  include /etc/nginx/conf.d/unicorn/server.conf;

  client_max_body_size 100m;
  error_page 413       /413.html;

  recursive_error_pages on;

  if ($request_filename ~ "version.txt") {
    break;
  }

  if ($request_filename ~ "/status/check") {
    break;
  }

  if (-f $document_root/system/maintenance) {
    return 503;
  }

  # rewrite asset urls to remove the SHA
  rewrite "^/[0-9a-f]{40}/(.*)" /$1 last;

  error_page 503 @503;
  location @503 {
    error_page 405 = /maintenance.html;

    if (-f $request_filename) {
      break;
    }

    rewrite ^(.*)$ /maintenance.html break;
  }

  location ~ ^/(images|javascripts|assets|stylesheets)/ {
    add_header Cache-Control public;
    expires modified +720h;
  }

  location ~ \.(html|ico)$ {
    add_header Cache-Control public;
    expires modified +720h;
  }

my unicorn/server.conf 

try_files $uri @app;

location @app {
 
  proxy_pass http://app_server;

}

unicorn/upstream.conf

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

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,216297,216297#msg-216297



More information about the nginx mailing list