phusion / passenger

A fast and robust web server and application server for Ruby, Python and Node.js
https://www.phusionpassenger.com/
MIT License
5k stars 547 forks source link

/subdomain duplicates when using PassengerBaseURI #2147

Open ghost opened 5 years ago

ghost commented 5 years ago

Issue report

Question 1: What is the problem? I tried setting up passenger with subdomain configuration, but it won't work as much as I expected. I expected url like http://my-rails.app/app1, but it actually behaved like http://my-rails.app/app1/app1.
I'm using symbolic link, which links from /var/www/html/app1 to /home/username/rails-app and on my server, this application works alone.
If there is no PassengerBaseURI, it works as expected. here is my passenger configuration file.

<VirtualHost *:80>
  RailsEnv staging
  PassengerEnabled on
  ServerName my-rails.app
  LogLevel debug
  DocumentRoot /var/www/html/app1

  Alias /app1 /var/www/html/app1
  <Location /app1 >
    PassengerBaseURI /app1
    PassengerAppRoot /home/username/rails-app
    SetEnv DATABASE_URL xxxxx://xxx:xxx@xx.xx.xx.xxx:xxxx/xxxx
    SetEnv SECRET_KEY_BASE xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    SetEnv RAILS_RELATIVE_URL_ROOT /app1
  </Location>
  <Directory /var/www/html/app1>
    Allow from all
    Options -MultiViews
    Require all granted
  </Directory>
</VirtualHost>

LoadModule passenger_module /home/username/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/passenger-5.3.7/buildout/apache2/mod_passenger.so
<IfModule mod_passenger.c>
  PassengerInstanceRegistryDir /home/username/passenger-tmp
  PassengerRoot /home/username/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/passenger-5.3.7
  PassengerDefaultRuby /home/username/.rbenv/versions/2.5.3/bin/ruby
</IfModule>

Question 2: Passenger version and integration mode: open source 5.3.7/apache2.4.29

Question 3: OS or Linux distro, platform (including version): Ubuntu 18.04.1 LTS

Question 4: Passenger installation method:

[x] RubyGems + Gemfile [ ] RubyGems, no Gemfile [ ] Phusion APT repo [ ] Phusion YUM repo [ ] OS X Homebrew [ ] source tarball [ ] Other, please specify:

Question 5: Your app's programming language (including any version managers) and framework (including versions): Ruby2.5.3, rbenv, Rails5.2.0

Question 6: Are you using a PaaS and/or containerization? If so which one? passenger working on physical machine

Question 7: Anything else about your setup that we should know? no.

pscdodd commented 5 years ago

Try changing «<VirtualHost *:80>» to «» and so on for all your virtual hosts. See https://httpd.apache.org/docs/2.4/vhosts/examples.html .

CamJN commented 5 years ago

Are you seeing incorrect links generated or is your app receiving requests with incorrect paths?

ghost commented 5 years ago

Thank you for reply and I'm sorry to my late response, but there is still incorrect response from server. My application server said The requested URL /app1/sign_in/path was not found on this server. and return 404. I check my symlink but it certainly link to application's public folder.

CamJN commented 5 years ago

I'm sorry, to clarify before it seemed that you were receiving requests like http://my-rails.app/app1/app1 and in this reply you only have one instance of /app1. Do you want the /app1 stripped off completely or are you seeing two copies of /app1?