【问题标题】:Nginx 404 error when navigation from main / home page to another one (Rails 5, AWS EC2)从主/主页导航到另一个页面时出现 Nginx 404 错误(Rails 5,AWS EC2)
【发布时间】:2016-09-21 16:48:46
【问题描述】:

导航到我的应用主页中的链接页面时出现此错误。

我正在使用 Nginx 和Passenger

application/_header.html.erb 文件中,我有此行作为链接:

<li><%= link_to 'Comments', comments_path, method: "get" %></li>

routes.rb 我有: root to: "application#index" resources :comments

我的/etc/nginx/sites-available/default

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

        root /home/ubuntu/test-aws-deploy-with-git-ec2-rds/public;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name ec2-54-173-78-253.compute-1.amazonaws.com;

        location / {
                proxy_pass http://127.0.0.1:4000;
                proxy_http_version 1.1;
                proxy_buffering off;
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
        }
}

不知道为什么我无法在此应用中的页面之间导航? 我需要在某个地方指定此应用将使用的任何页面吗?

【问题讨论】:

    标签: ruby-on-rails nginx amazon-ec2 passenger


    【解决方案1】:

    为此,您需要在 /etc/nginx/sites-available/default 中的以下行发表评论

      location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =404;
        }
    

    它的工作我也遇到了同样的问题。

    【讨论】:

      猜你喜欢
      • 2021-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-09
      • 2021-06-05
      • 2015-08-02
      • 1970-01-01
      相关资源
      最近更新 更多