【问题标题】:Rails+passenger+nginx run app with url without :portRails+passenger+nginx 使用 url 运行应用程序,但没有 :port
【发布时间】:2013-02-18 14:56:07
【问题描述】:

我有一个 rails 应用程序...我安装了 chain: nginx+passenger 并运行 rails server。但我的问题是,在浏览器中我必须设置 url,如:

page.com:3000

但是如何只使用 page.com?

我无法运行用户限制命令passenger start -e=development -p=80......

我的nginx conf文件是这样的:

server {
        listen      80;
        server_name  localhost;

        #charset koi8-r;
        #root /home/prog/OnlineAuto/Shop/public;
        #passenger_enabled on;
        #access_log  logs/host.access.log  main;
        location / {
                root /home/prog/OnlineAuto/Shop/public;
                index  index.html index.htm;
                passenger_enabled on;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
}

那么,如何在没有任何端口的情况下按域获取我的 rails 应用程序? (但在 3000 端口上运行 rails 服务器)

【问题讨论】:

    标签: ruby-on-rails nginx passenger


    【解决方案1】:

    您尝试在 Nginx 使用的同一端口上启动乘客,这可能是您收到错误的原因。

    我对 Unicorn 更熟悉,但根据我阅读的文档,您不必在单独的进程中启动Passenger。正确安装Passenger后,我认为您只需要Nginx指令即可使其工作。

    nginx.conf的http块中配置你的passenger_root和passenger_ruby,然后

    http {
      passenger_root /<path_to_passenger_install>;
      passenger_ruby /usr/local/bin/ruby;
    
      server {
        listen 80;
        server_name page.com;
        charset utf-8;
        root /www/page.com/public;
        passenger_enabled on;
        rails_spawn_method smart;
        rails_env development;
      }
    }
    

    【讨论】:

    • 我通过密码获取的公共路径
    • 你有任何来自 nginx 的错误日志可以分享吗?你使用的是什么版本的乘客/rails/nginx?
    • 铁路 3.2.8 乘客 3.0.19
    • 也不好用nginx+passenger还是更好用的nginx+unicorn?
    • 根据 linux 发行版,nginx 日志通常可以在/var/log/nginx 中找到。具体看error.log
    【解决方案2】:

    如果你在这里使用乘客,我必须使用它来让它在 www.mysite.com 上运行,而无需在 centos 服务器上使用 www.mysite.com:80:

    在 etc/httpd/conf 中,关键是取消注释 NameVirtualHost *:80 并将 * 更改为我的服务器的 IP 地址。确保未注释 Listen 80。还将您的 ip 添加到 VirtualHost 标签。它必须在端口 80 上运行,而不是 8080 或您选择的端口。

    NameVirtualHost xx.xx.xx.xx:80  
    
    Listen 80  
    
    <VirtualHost xx.xx.xx.xx:80>
        ServerName www.mysite.com
        # !!! Be sure to point DocumentRoot to 'public'!
        DocumentRoot /var/www/vhosts/mysite.com/httpdocs/public/
        <Directory /var/www/vhosts/mysite.com/httpdocs/public/>
           # This relaxes Apache security settings.
           AllowOverride all
           # MultiViews must be turned off.
           Options -MultiViews
        </Directory>
    </VirtualHost>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-16
      • 2016-06-21
      • 2019-04-12
      • 2013-10-31
      • 1970-01-01
      • 1970-01-01
      • 2013-06-22
      • 2013-06-14
      相关资源
      最近更新 更多