1

軌處理子域名我也跟着上multitenant 簡單railscasts插曲現在在我的應用程序的所有住戶進入自己的子域名,其對我的開發系統的研究與開發,但溫家寶在本地工作我盡我的VPS系統在這個同樣的過程,瀏覽器說找不到服務器。如何與麒麟,和nginx的

我連接了域名我的IP,並修改了我的nginx的文件,仍然沒有希望

一旦用戶輸入他的子域,請求沒有得到我的rails應用程序。

任何想法對此或我可能沒有得到正確的。由於

我nginx_unicorn_file

upstream unicorn { 
    server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0; 
} 

server { 
    listen 80 default deferred; 
    server_name shopnany.com *.shopnany.com; 
    root <%= current_path %>/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; 
} 

回答

1

我沒有問題,這樣做。首先,您需要在您使用的任何DNS提供商中創建一條A記錄。例如創建DNS記錄:

it.shopnany.com

那麼你就必須更新你的nginx的配置模板,這個特別的部署。它可以如下:

upstream unicorn_<%= application %> { 
    server unix:/tmp/unicorn.<%= application %>.sock fail_timeout=0; 
} 

server { 
    listen 80; 
    server_name it.shopnany.com; 
    root <%= current_path %>/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_<%= application %>; 
    } 

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

這對我有效。現在我有兩個不同的應用程序在我的www和它的子域上運行。

+2

經過深入研究,我發現我必須爲c記錄*創建一個通配符,客戶可以在不知道我的情況下創建多個子域,所以我不必爲個人客戶創建c記錄。如果主應用程序找不到子域,則它會處理對主應用程序的請求。很簡單 – Uchenna