2012-04-26 71 views
1

我一直在關注瑞安B的VPS部署railscast:將capistrano的子域部署到nginx/unicorn設置 - 如何?

http://railscasts.com/episodes/335-deploying-to-a-vps

nginx.conf文件,他建議使用不使用子工作。這是他顯示:

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

server { 
    listen 80 default deferred; 
    # server_name example.com; 
    root /home/deployer/apps/<app name>/current/public; 

    location ^~ /assets/ { 
    gzip_static on; 
    expires max; 
    add_header Cache-Control 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; 
    } 

    error_page 500 502 503 504 /500.html; 
    client_max_body_size 4G; 
    keepalive_timeout 10; 
} 

有誰知道如何設置支持子域的東西?

回答

0

事實證明(至少在linode.com中),handeling的通配符子域非常簡單。您只需將一臺*主機添加到A記錄。

此外,在nginix,我所做的就是更換:

# server_name example.com; 

有:

server_name localhost; 

我不知道,甚至需要。

我的實際問題與主機或nginx無關。我的情況是,在註冊期間我使用隨機哈希URL作爲安全性令牌(因此用戶不能劫持現有的子域),但是我使用的哈希類型存在問題,所以我需要修改它。

我沒有看到任何錯誤,我只是被重定向回註冊頁面 - 正如散列URL有問題/不匹配時的正確行爲。

無論如何,一旦我解決了這個問題,整個子域的事情就不成問題了。

希望這可以幫助其他任何使用散列URL,子域名並且通常對於部署不熟悉的人。

乾杯。

1

您可以取消行:

# server_name example.com;

與您的域名替換example.com和補充:

server_name example.com *.example.com;

server_name example.com blog.example.com;

現在,所有的請求域和子域名將轉到導航欄