nginx, passenger only showing root page, all other routes fail
Asked Answered
A

1

6

Nginx + passenger is only showing the root page / path, all other routes fail with 404 Not Found. I know nginx and passenger must be running to correctly bring up the root path. Here's the entry for sites-available:

    server {
      listen 80;
      server_name staging.redacted.com; # Replace this with your site's domain.

      passenger_enabled on;
      passenger_app_env staging;

      keepalive_timeout 300;

      client_max_body_size 4G;

      root /var/www/staging.redacted.com/current/public; # Set this to the public folder location of your Rails application.

      #try_files $uri/index.html $uri.html $uri;
      try_files $uri $uri/ =404;

    }

routes.rb - even though they all work and pass their specs.

    Rails.application.routes.draw do

      resources :users

      resources :brand_api_keys

      resources :ir_service_buckets
      resources :ir_service_images
      resources :ir_services do
        resources :ir_service_buckets do
          resources :ir_service_images
        end
      end
      resources :devices do
        resources :scans
      end
      resources :images do
        resources :scans
      end
      resources :campaigns do
        resources :images
      end
      resources :agent_brands
      resources :brands do
        resources :brand_api_keys
        resources :ir_service_buckets do
          resources :ir_service_images
        end
        resources :agent_brands
        resources :campaigns
      end
      resources :agents do
        resources :brand_api_keys
        resources :agent_brands
      end

      root 'agents#index'
    end
Aubert answered 14/2, 2015 at 22:45 Comment(1)
Please, attach your routes.rb file.Dahna
S
17

Try removing try_files $uri $uri/ =404; Remove or comment out the try_files line completely and it will work.

Stettin answered 15/2, 2015 at 9:43 Comment(5)
Moving try_files to a location block didn't help, it wasn't even showing the root path like that. I'm not getting any errors in either the the nginx or app logs.Aubert
Provide us an access.log entry about accessing URL which works and which isn't working please.Stettin
I've read about passenger a little — could you please test with "try_files" removed completly?Stettin
It worked! without any try_files it works perfectly! thanks so much, very appreciated. Please create an answer so i can accept it! :)Aubert
This is an old answer but man you saved me a bunch of headache!Jerrelljerri

© 2022 - 2024 — McMap. All rights reserved.