2011-11-17 3 views
7

Railscasts 에피소드 # 293에서 설명한대로 nginx 및 unicorn에서 실행되도록 설정했습니다. 내가 http://unicorn/posts 대신nginx 및 unicorn 설정에서 레일 리다이렉트가 실패합니다

http://mydomain.com/posts의로 리디렉션 등

class PostsController < ApplicationController 
    def show 
    redirect_to posts_path, :notice => "Test redirect" 
    end 
end 

내가 리디렉션하려고

는 여기이 나를 위해 작동하는 응용 프로그램

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

server { 
    listen 80 default deferred; 
    # server_name example.com; 
    root /var/apps/current/public; 

    try_files $uri/index.html $uri @unicorn; 

    location @unicorn { 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_pass http://unicorn; 
    } 

    keepalive_timeout 5; 
} 
+0

내가 대신 내가 가진 위치 @의 unicorn''위치 /''의, 비슷한 설정을 가지고있다. 너 그거 해봤 니? – Frost

+0

@MartinFrost 그래, 도움이되지 않았다. 그것이 나에게 그것은 도메인 이름 대신 기본 URL로 proxy_pass URL을 사용하는 것으로 보입니다. –

+0

'./config/unicorn.rb' 콘텐츠도 게시 할 수 있습니까? 예 : 'listen' 지시어가있는 줄. – Tilo

답변

5

내 nginx.conf의 :

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

server { 
    listen  80; 
    listen  localhost; 
    server_name www.example.com; 
    keepalive_timeout 5; 

    location/{ 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    # this is required for HTTPS:                                                            
    # proxy_set_header X-Forwarded-Proto https; 
    proxy_set_header Host $http_host; 
    proxy_redirect off; 
    proxy_pass http://unicorn; 
    } 

} 
(210)

내 ./config/unicorn.rb 파일 :

# Listen on a Unix data socket                                                                     
listen "/tmp/unicorn.example.sock", :backlog => 64 
관련 문제