# Ruby p290p; nginx 1.0.;8 unicorn url redirect

**URL:** <https://www.ruby-forum.com/t/ruby-p290p-nginx-1-0-8-unicorn-url-redirect/212559>\
**Category:** NGINX\
**Created:** [October 6, 2011, 4:54am UTC](https://www.ruby-forum.com/t/ruby-p290p-nginx-1-0-8-unicorn-url-redirect/212559 "2011-10-06T04:54:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [October 6, 2011, 4:54am UTC](https://www.ruby-forum.com/t/ruby-p290p-nginx-1-0-8-unicorn-url-redirect/212559/1 "2011-10-06T04:54:38Z")

</div>

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](http://games.example.com);  
rewrite ^(.\*) [http://www.example.com/games](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:

> **[ruby p290p; nginx 1.0.;8 unicorn url redirect](https://forum.nginx.org/read.php?2,216297,216297#msg-216297)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![danzel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e19b73/32.png) [@danzel](https://www.ruby-forum.com/u/danzel)\
**Post date:** [October 6, 2011, 6:23am UTC](https://www.ruby-forum.com/t/ruby-p290p-nginx-1-0-8-unicorn-url-redirect/212559/2 "2011-10-06T06:23:54Z")

</div>

taken out ruby and rvm system wide and unicorn config on the nginx but  
nginx still redirects.

Posted at Nginx Forum:

> **[Re: ruby p290p; nginx 1.0.;8 unicorn url redirect](https://forum.nginx.org/read.php?2,216297,216299#msg-216299)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![danzel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e19b73/32.png) [@danzel](https://www.ruby-forum.com/u/danzel)\
**Post date:** [October 6, 2011, 8:42am UTC](https://www.ruby-forum.com/t/ruby-p290p-nginx-1-0-8-unicorn-url-redirect/212559/3 "2011-10-06T08:42:39Z")

</div>

another update: using server\_name localhost; or private ipaddress, it  
always redirect but using public hostname the nginx is functioning well.  
Anyway how to bypass this one? thanks

Posted at Nginx Forum:

> **[Re: ruby p290p; nginx 1.0.;8 unicorn url redirect](https://forum.nginx.org/read.php?2,216297,216302#msg-216302)**
>
> 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...
