2013-05-10 63 views
2

我與aws混淆,並且想要將多個應用程序部署到我的免費層aws帳戶。Nginx,獨角獸和子軌道中的多軌應用程序

我想有nginx的點「ec-2-site.com/first-app」和「ec-2-site.com/second-app。

這裏是我當前的配置文件(基本上是猜測,並從this railscast

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

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

server { 
    listen 80 default deferred; 

    location /chaos/ { 
    #server_name http://ec2-50-16-81-170.compute-1.amazonaws.com/chaos; 
    root /home/deployer/apps/chaos/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_chaos; 
    } 

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

    location /blog/ { 
    # server_name example.com; 
    root /home/deployer/apps/blog/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)blog; 
    } 

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

這裏檢查是我得到的錯誤:

nginx: [emerg] named location "@unicorn_chaos" can be on the server level only in /etc/nginx/sites-enabled/chaos:23 

顯然,這@unicorn_appname指令不應該存在,但這裏應該是我要去回合所有這一切G?

感謝

+0

一個天真的問題,但是上面給出的'http {}'塊內的整個代碼? – Kashyap 2013-05-11 04:23:30

+1

你是如何解決這個問題的? – 2013-07-09 09:04:29

+0

我沒有解決它。這是一個個人aws服務器,從那以後我一直沒有做過這方面的工作。 – Squadrons 2013-07-09 14:56:34

回答

1

我沒有檢查railscast但我發現在你的配置一些問題。

首先是在第50行,你拼錯地址。

其次是你應該把位置命名的位置。

層次結構看起來像這樣

server 
    location app1 
     try_files @unicorn 
     location @unicorn 
      proxy_pass unicorn_app1 
    location app2 
     try_files @unicorn 
     location @unicorn 
      proxy_pass unicorn_app2 

試試這個

server 
    location app1 
     try_files unicorn_app1 
    location @unicorn_app1 
     proxy_pass unicorn_app1 

    location app2 
     try_files @unicorn_app2 
    location @unicorn_app2 
     proxy_pass unicorn_app2 

重要的是要保持自己的名字獨特,並把它們放在同一服務器水平。

相關問題