Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5993103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:37:38+00:00 2026-05-22T23:37:38+00:00

I have a Sinatra-based app that runs fine locally. I moved it to a

  • 0

I have a Sinatra-based app that runs fine locally.

I moved it to a nginx-based server with Passenger and now all my links to files in my apps /public are returning 404 errors. The primary app runs, is able to access the HAML templates in /view, which render correctly. The files exist and permissions are correct; I can open and edit them so I know they’re there.

In my HAML templates I’m referring to the files that I can’t access like this:

%script{ :src => 'js/jquery.js' }
%link{ "rel" => "stylesheet", "href" => "styles/input.css" }

My config.ru has gone through a lot mutations while I try to find the problem. Currently I have:

require 'sinatra'
require './peering_template.rb'

root_dir = File.dirname(__FILE__)

# disable :run
# set :root, root_dir
# set :views, File.join(File.dirname(__FILE__), 'views')
# set :environment, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)

run Sinatra::Application 

The app exists in /home/apps/peering_template.

The web space is /home/webapps.

There is a soft-link in /home/webapps like this: peering_template -> /home/apps/peering_template/public/.

/home/webapps/
`-- peering_template -> /home/apps/peering_template/public/

The pertinent part of nginx.conf for this config is:

server {
    listen      3000;
    server_name my_servers_name;
    root        /home/webapps;

    passenger_enabled  on;
    passenger_base_uri /peering_template;
}

Obviously, my server’s name is different.

The pertinent part from nginx’ error.log is like this:

"/home/webapps/js/jquery.js" failed (2: No such file or directory), request: "GET /js/jquery.js HTTP/1.1"

As near as I can tell this fits the directions for an “nginx and passenger configuration using sub-URIs“. What am I missing?


/home/apps/peering_template/
|-- config.ru
|-- lib
|   |-- bgp-config.rb
|   |-- ios-xr-config.rb
|   |-- ipv4_ipv6_grammar.rb
|   `-- ipv4_ipv6_grammar.treetop
|-- nginx.conf
|-- peering_template.rb
|-- public
|   |-- js
|   |   |-- jquery-1.6.min.js
|   |   |-- jquery-ui-1.8.12.custom.zip
|   |   |-- jquery.js -> jquery-1.6.min.js
|   |   `-- scripts.js
|   |-- peering_template_tool.htm
|   `-- styles
|       `-- input.css
|-- spreadsheets
|   |-- Peering Template-AMS-IX.xlsx
|   `-- Peering Template-IOS-XR-ASH1.xlsx
|-- tmp
|   `-- always_restart.txt
`-- views
    |-- index.haml
    `-- output.haml

I’m not sure if it matters but this is on a CentOS release 5.3 (Final) host, running nginx/1.0.0 and passenger (3.0.7).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:37:39+00:00Added an answer on May 22, 2026 at 11:37 pm

    In the original question I wrote:

    I moved it to a nginx-based server with Passenger and now all my links to files in my apps /public are returning 404 errors. The primary app runs, is able to access the HAML templates in /view, which render correctly. The files exist and permissions are correct; I can open and edit them so I know they’re there.

    That was my clue. On my fourth pass or so through the Passenger docs I ran into a section that talked about errors with /public assets:

    The second and highly recommended way is to always use Rails helper methods to
    output tags for static assets. These helper methods automatically take care of
    prepending the base URI that you’ve deployed the application to. For images
    there is image_tag, for JavaScript there is javascript_include_tag and for CSS
    there is stylesheet_link_tag. In the above example you would simply remove the
    HTML tag and replace it with inline Ruby like this:

    So, that got me searching for similar helpers for Sinatra. I found in Sinatra’s extensions page:

    sinatra-url-for construct absolute paths and full URLs to actions in a Sinatra application

    sinatra-static-assets implements image_tag, stylesheet_link_tag, javascript_script_tag and link_tag helpers. These helpers construct correct absolute paths for applications dispatched to sub URI.

    And that got me searching Sinatra’s docs because it sparked a memory, and I relearned Sinatra’s built-in “url” method:

    Generating URLs

    For generating URLs you should use the url helper method, for instance, in
    Haml:

    %a{:href => url(‘/foo’)} foo

    It takes reverse proxies and Rack routers into account, if present.

    This method is also aliased to to (see below for an example).

    By using the static asset methods, or Sinatra’s own url helper it fixed the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Scenario I have a Sinatra App I have a route that fetches articles based
I have a Sinatra app that runs inside of EventMachine. Currently, I am taking
I have a Sinatra DataMapper app hitting a sqlite3 database that I am attempting
I have a Sinatra app that, boiled down, looks basically like this: class MyApp
I have a Sinatra app, that uses omniauth which constantantly gets this error attack
I have a Sinatra::Base object that I would like to include in all of
I have web.rb file that works fine. I wanted to move all require files
I have a sinatra app running locally and awhile back I ran into an
I have a simple Sinatra app that is configured using the modular style. When
I have deployed a Sinatra application on an Ubuntu server using Apache and Passenger.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.