Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to deploy as sub URI as seen in doc #1158

Closed
FooBarWidget opened this issue May 29, 2014 · 12 comments
Closed

Unable to deploy as sub URI as seen in doc #1158

FooBarWidget opened this issue May 29, 2014 · 12 comments

Comments

@FooBarWidget
Copy link
Member

From adrianlzt on February 10, 2014 16:24:51

What steps will reproduce the problem? 1. Follow doc until point 4.3 ( http://www.modrails.com/documentation/Users%20guide%20Apache.html#_deploying_a_rack_based_ruby_application_including_rails_gt_3 )
2. Apache returns 403 What is the expected output? What do you see instead? "Hello world" What version of Phusion Passenger are you using? Which version of Rails? On what operating system? Rails 4.0.2
Apache/2.2.1
Phusion_Passenger/4.0.37
CentOS 6.4 Please provide any additional information below. Using this configuration file por apache:
RailsBaseURI /subapp
<Directory /websites/rack/public>
Allow from all
Options -MultiViews
RailsEnv production

And creating this soft link:
ln -s /websites/rack/public /var/www/html/subapp

Works correctly

Original issue: http://code.google.com/p/phusion-passenger/issues/detail?id=1059

@thoughtafter
Copy link

This is still an issue. The documented way to deploy to a sub-uri does not work as documented here:
https://www.phusionpassenger.com/library/deploy/apache/deploy/ruby/#deploying-an-app-to-a-sub-uri

@FooBarWidget
Copy link
Member Author

@thoughtafter Can you describe your issue in more detail? How exactly does your configuration look like, and what behavior do you observe? Any error messages?

@thoughtafter
Copy link

This works, as does creating a symlink as described above:

<VirtualHost *:80>
  ServerName servername
  DocumentRoot /var/www/app/current/public
  Alias /app /var/www/app/current/public
  <IfModule mod_passenger.c>
    PassengerEnabled on
     PassengerBaseURI /app
   PassengerAppRoot /var/www/app/current
  </IfModule>
  <Directory /var/www/app/current/public>
    AllowOverride none
    Options SymLinksIfOwnerMatch
    Require all granted
  </Directory>
</VirtualHost>

This, which is the way it should work according to the documentation, using a location directive, does not work:

<VirtualHost *:80>
  ServerName servername
  DocumentRoot /var/www/app/current/public
  Alias /app /var/www/app/current/public
<Location /app>
  <IfModule mod_passenger.c>
    PassengerEnabled on
     PassengerBaseURI /app
   PassengerAppRoot /var/www/app/current
  </IfModule>
</Location>
  <Directory /var/www/app/current/public>
    AllowOverride none
    Options SymLinksIfOwnerMatch
    Require all granted
  </Directory>
</VirtualHost>

Error: "The requested URL /app/ was not found on this server."

@OnixGH
Copy link
Contributor

OnixGH commented Sep 17, 2015

@thoughtafter both your configs work for me (without symlinking anything) on Ubuntu 14.04 with Apache 2.4 and Passenger 5. What system did you test on?

@tebayoso
Copy link

I have this setup in my virtualhost and seems to be working fine, maybe it can help.
Capistrano folder architecture, no symlinks others than capis defaults
Centos 7 + Apache(httpd) + Passenger 5 + Ruby 2

<VirtualHost *:80>
   ServerName vision.staging.decisiv.net
   ServerAlias www.vision.staging.decisiv.net
   DocumentRoot /var/www/DecisivView/current/public
   <Directory /var/www/DecisivView/current/public>
      Allow from all
      Options -MultiViews
      Require all granted
      RailsEnv staging
   </Directory>

   # Sub Uri app
   Alias /qcadmin /var/www/decisiv-qc/current/public
   <Location /qcadmin>
      PassengerBaseURI /qcadmin
      PassengerAppRoot /var/www/decisiv-qc/current

   </Location>
   <Directory /var/www/decisiv-qc/current/public>
     Allow from all
     Options -MultiViews
     Require all granted
     RailsEnv staging
   </Directory>
</VirtualHost>

@thoughtafter
Copy link

This is also Ubuntu 14.04 with Apache 2.4 and Passenger 5.
Is there a way to debug this? I've tried passenger-config:

passenger-config  list-instances
Name                       Description
------------------------------------------------------------------
aL0hkx6w                   Apache/2.4.7 (Ubuntu) Phusion_Passenger/5.0.18

So the rails application is clearly being created, but it's not accessible at the location path, nor at the root path.

@thoughtafter
Copy link

Works:

<VirtualHost *:80>

    PassengerEnabled on
    DocumentRoot /var/www/app/current/public
    Alias /demo /var/www/app/current/public

    PassengerAppEnv demo
    PassengerBaseURI /demo
    PassengerAppRoot /var/www/app/current

  <Directory /var/www/app/current/public>
    Options -MultiViews
    Require all granted
  </Directory>
</VirtualHost>

By adding location block the app is created but RAILS_RELATIVE_URL_ROOT is not set in the env and thus /demo is attempted to be interpretted as a route and the error is ActionController::RoutingError.

<VirtualHost *:80>

    PassengerEnabled on
    DocumentRoot /var/www/app/current/public
    Alias /demo /var/www/app/current/public

<Location /demo>
    PassengerAppEnv demo
    PassengerBaseURI /demo
    PassengerAppRoot /var/www/app/current
</Location>

  <Directory /var/www/app/current/public>
    Options -MultiViews
    Require all granted
  </Directory>
</VirtualHost>

In this example, analogous to my post above, PassengerEnabled has been moved into the Location block. This causes apache to fail to forward to passenger and the error is an apache 404:

<VirtualHost *:80>

    DocumentRoot /var/www/app/current/public
    Alias /demo /var/www/app/current/public

<Location /demo>
    PassengerEnabled on
    PassengerAppEnv demo
    PassengerBaseURI /demo
    PassengerAppRoot /var/www/app/current
</Location>

  <Directory /var/www/app/current/public>
    Options -MultiViews
    Require all granted
  </Directory>
</VirtualHost>

So my example above failed because of this last case, that PassengerEnabled doesn't work within a Location block. However, now it is case 2 that interests me, why PassengerBaseURI seems to fail when within a location block.

@thoughtafter
Copy link

Another piece of info:
Turning off PassengerHighPerformance fixes case 2 above.

Bugs:

  1. PassengerEnabled fails in Location block.
  2. Loading sub-uri via location block fails when PassengerHighPerformance enabled.

@OnixGH
Copy link
Contributor

OnixGH commented Oct 12, 2015

@thoughtafter hmm, I copy pasted case 1 and it's working for me (I only changed PassengerAppEnv from demo to development). My app is accessible at localhost/demo/.

As for case 2, it's best to paste the exact config when reporting, so that we would have seen you were using PassengerHighPerformance. Our docs explicitely warn that it can interfere with other Apache modules; in this case it seems to be messing up mod_alias. That's unfortunate, but considered to be a known caveat.

@FooBarWidget
Copy link
Member Author

Speaking of which, maybe I should get rid of PassengerHighPerformance altogether. It was originally written as an optimization in benchmarks, but everybody who benchmarks Passenger nowadays would either use the Nginx integration mode or the Standalone mode with builtin engine. I regularly see people using PassengerHighPerformance while not reading the caveats.

@thoughtafter
Copy link

PassengerHighPerformance should probably be removed if it interferes with mod_alias. At the very least that should be added to known problematic modules along with mod_rewrite and mod_autoindex. Also, bug 1 also appears to be due to PassengerHighPerformance interfering with mod_alias in a way that prevents PassengerEnabled from working properly.

Obviously once I realized this system had additional passenger configuration set in a non-obvious included file my plan was to post that, but before doing so I started disabling the options one by one until I disabled PassengerHighPerformance and found that resolved the issues. I agree that people should look for such things not just by grepping for the passenger options but also for include statements that may be outside the apache directory, which is what bit me in this case. I apologize for not having better information sooner.

@OnixGH
Copy link
Contributor

OnixGH commented Oct 13, 2015

@thoughtafter that explains it indeed, no worries. I should also remember to ask about checking for additional config files when it "just works" for me.

I'll close this issue, since the docs have changed and it doesn't appear reproducible in 5.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants