繁体   English   中英

在Ruby on Rails 5.2中,如何使我的网站显示“欢迎使用Rails”而不是“ /的索引”?

[英]How do I get my website to display Welcome to Rails instead of Index of / in Ruby on Rails 5.2?

duelingpetWS2小站地址: http ://68.183.163.139/

当前已安装:

NodeJS
NPM
Rbenv
ruby 2.5.1p57
Rails 5.2.2
MySQL
Ubuntu 18.04
nginx

/var/www/duelingpets.net/html/index.html

<html>
    <head>
        <title>Welcome to Duelingpets.net!</title>
    </head>
    <body>
        <h1>Success!  The duelingpets.net server block is working!</h1>
    </body>
</html>

新版本/etc/nginx/sites-available/duelingpets.net

upstream duelingpets {
  server unix:///path/to/web/tmp/puma.sock;
}

server {
        listen 80;
        listen [::]:80;

        root /var/www/duelingpets.net/html;
        #index index.html index.htm index.nginx-debian.html;
        server_name duelingpets.net www.duelingpets.net;
        try_files $uri @app;

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

旧版本/etc/nginx/sites-available/duelingpets.net

server {
        listen 80;
        listen [::]:80;

        root /var/www/duelingpets.net/html;
        index index.html index.htm index.nginx-debian.html;

        server_name duelingpets.net www.duelingpets.net;

        location / {
                try_files $uri $uri/ =404;
        }
}

须藤ln -s /etc/nginx/sites-available/duelingpets.net / etc / nginx / sites-enabled /

须藤vim /etc/nginx/nginx.conf

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        # server_tokens off;

        server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

网站的当前行为。

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.

Thank you for using nginx.

我想您正在将Puma用作Rails的应用服务器,请检查此票证: https : //github.com/puma/puma/issues/125

它设置此配置

<VirtualHost *:80>
    NameVirtualHost 99.99.99.99
    ServerName yourapp.com
    ServerSignature Off
    ProxyRequests Off
    <Proxy *>
        Order Allow,Deny
        Allow from all
    </Proxy>
    ProxyPass / http://localhost:3000/
    ProxyPassReverse / http://localhost:3000/
    ProxyVia On
</VirtualHost>

请注意localhost:3000的proxypass,这是重要的部分(您不需要文档根)。

并确保使用puma -b tcp://127.0.0.1:3000启动puma,以便它可以通过tcp而不是套接字工作。

无论如何,我更喜欢使用nginx而不是apache,您可以将nginx设置为使用套接字,这是默认情况下puma的启动方式,并且还有更多有关nginx + puma的教程(该链接上也有nginx的配置)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM