Push redmine to the root of a subdomain - ruby-on-rails

I just installed redmine and I would like to reach it from redmine.domain.com instead of domain.com/redmine.
I first tried to do this by myself with my few Apache knowledge but I got the following error:
So I looked for a support on the internet and found this page. I consequently adapted my Apache configuration file:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName redmine.mydomain.com
ServerAdmin admin#mydomain.com
DocumentRoot /var/www/redmine
<Directory /var/www/redmine>
Allow from all
Options -MultiViews
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined
SSLEngine on
SSLCertificateFile /etc/ssl/private/redmine.mydomain.com.crt
SSLCertificateKeyFile /etc/ssl/private/redmine.mydomain.com.key
</VirtualHost>
</IfModule>
And made some check ups, all seems good. However, when I go to my redmine.mydomain.com I see the hierarchy of /usr/share/redmine/public.

To cite from the page you linked to:
The virtual host’s document root must point to your Rack application’s public folder.
Thus, you have to configure Apache's DocumentRoot to point to /var/www/redmine/public.

Related

Trouble configuring a sub-uri with Apache 2, Rails 3.2, and Phusion Passenger

I need some help getting a Rails 3.2 app working in a sub-uri of a cPanel-configured Apache site. I've followed the steps from the Passenger docs and various blog posts. The root action renders fine, but every other request gives me a 404.
I think it is something in the Apache, not Rails, config, because it's not the Rails app's 404 page, and the 404s do not leave traces in the Rails log.
Here is the vhost section from httpd.conf, generated by cPanel:
<VirtualHost myip:443>
ServerName mysite.org
ServerAlias www.mysite.org
DocumentRoot /home/myuser/public_html
ServerAdmin webmaster#mysite.org
UseCanonicalName Off
Options -ExecCGI -Includes
RemoveHandler cgi-script .cgi .pl .plx .ppl .perl
CustomLog /usr/local/apache/domlogs/mysite.org combined
CustomLog /usr/local/apache/domlogs/mysite.org-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User myuser # Needed for CPanel::ApacheConf
UserDir disabled
UserDir enabled myuser
<IfModule mod_suphp.c>
suPHP_UserGroup myuser myuser
</IfModule>
<IfModule !mod_disable_suexec.c>
<IfModule !mod_ruid2.c>
SuexecUserGroup myuser myuser
</IfModule>
</IfModule>
<IfModule mod_ruid2.c>
RUidGid myuser myuser
</IfModule>
SSLEngine on
SSLCertificateFile /etc/ssl/certs/mysite.org.crt
SSLCertificateKeyFile /etc/ssl/private/mysite.org.key
SSLCACertificateFile /etc/ssl/certs/mysite.org.cabundle
CustomLog /usr/local/apache/domlogs/mysite.org-ssl_log combined
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
<Directory "/home/myuser/public_html/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
Include "/usr/local/apache/conf/userdata/ssl/2/myuser/mysite.org/*.conf"
</VirtualHost>
Here is the current version of the include file I put together for the sub-uri:
RewriteEngine On
RewriteOptions Inherit
RailsEnv production
<Directory /home/myuser/public_html>
Options Indexes FollowSymLinks -MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>
RackBaseURI /home/myrailsapp/current
<Directory /home/myuser/public_html/railsapp>
Options -MultiViews
</Directory>
/home/myuser/public_html/railsapp is a symlink to /home/myrailsapp/current/public
Here is /home/myrailsapp/current/public/.htaccess
RackBaseURI /railsapp
SetEnv GEM_HOME /usr/local/lib/ruby/gems
PassengerEnabled On
PassengerAppRoot /home/myrailsapp/current/
All files in /home/myrailsapp and /home/mysite are owned by myuser. (I'm not seeing any permissions errors.)
In my routes file:
resources :widgets
root :to => 'widgets#index'
When I navigate to https://mysite.org/railsapp it correctly displays the widgets index, including assets. When I go to https://mysite.org/railsapp/widgets or https://mysite.org/railsapp/widgets/index, I get the Apache 404, and no entry in the Rails log.
What am I missing?
It turns out .htaccess in /home/myuser/public_html was rewriting everything. Requests for /mysite/railsapp were exempted because it matched a directory name. I solved the problem by adding
RewriteEngine off
to /home/myrailsapp/current/public/.htaccess.
Adding RewriteEngine off to .htaccess does solve the problem.

Apache crashing when I add Far-Future Expires clause from Rails Guide

In an attempt to serve my precompiled assets with Apache, per this Rails Guide I try to change this:
<VirtualHost *:82>
ServerName localhost
DocumentRoot "C:/RubyStack-3.2.5-0/projects/release_checklist/public"
<Directory "C:/RubyStack-3.2.5-0/projects/release_checklist/public">
Allow from all
Options -MultiViews
</Directory>
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
ProxyPreserveHost On
</VirtualHost>
To this:
<VirtualHost *:82>
ServerName localhost
DocumentRoot "C:/RubyStack-3.2.5-0/projects/release_checklist/public"
<Directory "C:/RubyStack-3.2.5-0/projects/release_checklist/public">
Allow from all
Options -MultiViews
</Directory>
ProxyPass / http://localhost:3001/
ProxyPassReverse / http://localhost:3001/
ProxyPreserveHost On
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
# RFC says only cache for 1 year
ExpiresActive On
ExpiresDefault "access plus 1 year"
</LocationMatch>
</VirtualHost>
in my httpd.conf file. However, the Apache server won't start when the second option has been added. What am I doing wrong?
What error does it give you? Are you sure you have mod_expires compiled into apache and that the module is loaded?
Invalid command 'ExpiresActive', perhaps misspelled or defined by a module not included in the server configuration
Yeah, that's usually the error you get if you use a directive that's mapped to a module that isn't loaded (or just a mispelled directive, which appears the same to apache). You'll need to check httpd.conf and make sure the LoadModule expires_module modules/mod_expires.so line is not commented out, of if it's missing, to add it. Depending on your apache's version, the line can be slightly different.

Why does rails app show /public index listing instead of actual app?

How do you set up apache to show the rails app once it is on the server? My rails app works perfectly on the localhost, but when I go to the external site it gives me the index information
like this
Name Last modified Size Description
[TXT] 404.html 21-May-2012 21:38 728
[TXT] 422.html 21-May-2012 21:38 711
[TXT] 500.html 21-May-2012 21:38 643
[IMG] favicon.ico 21-May-2012 21:38 0
[TXT] robots.txt 21-May-2012 21:38 204
This is my virtual host information
<VirtualHost *:80>
ServerAdmin example#example.com
ServerName server.example.com
# ServerAlias
DocumentRoot /var/www/sample_app/current/public
ErrorLog /var/www/sample_app/error.log
RailsEnv production
<Directory "/var/www/sample_app/current/public">
Options Indexes FollowSymLinks MultiViews
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
OK that might not be it, but here's what Passenger's documentation recommends:
<VirtualHost *:80>
ServerName www.mycook.com
DocumentRoot /webapps/mycook/public
<Directory /webapps/mycook/public>
Allow from all
Options -MultiViews
</Directory>
</VirtualHost>
It's clearly stated that MultiViews is not compatible with Passenger.
So you could try:
Removing the Indexes option
Specifying -MultiViews instead of MultiViews
To be honest, I've tried adding Indexes to a production app of mine, as I thought that might just be this option that caused the problem, but it didn't change anything... so it's a bit of a "wild guess" that it might fix things on your side.
UPDATE
From another answer, what you could try is adding the PassengerResolveSymlinksInDocumentRoot option:
<VirtualHost *:80>
ServerName www.mycook.com
DocumentRoot /webapps/mycook/public
<Directory /webapps/mycook/public>
Allow from all
Options -MultiViews
PassengerResolveSymlinksInDocumentRoot on
</Directory>
</VirtualHost>

I can't see the images of the web debug toolbar

I can't see the images of the web debug toolbar.
I'm getting this error for example:
GET
http://francesca.localhost/web/sf/sf_web_debug/images/close.png
404 (Not Found)
If I request http://francesca.localhost/sf/sf_web_debug/images/close.png it works ok (the image is showed).
This is my virtual host:
<VirtualHost 127.0.0.1:80>
ServerName francesca.localhost
ServerAlias francesca.com
DocumentRoot /home/me/programacion/francesca
<Directory /home/me/programacion/francesca/web>
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch
Allow from All
</Directory>
Alias /sf /home/me/programacion/francesca/lib/vendor/symfony/data/web/sf
<Directory "/home/me/programacion/francesca/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
sf 1.4
Javi
You must have DocumentRoot /home/me/programacion/francesca/web

New Rails + Passenger deployment half working...not sure why?

I'm in the final stages of going round trip through the entire Rails cycle: development -> test -> production (on an external server). I'm very close...but seeing some errors with the production version and don't know enough about Rails' "magic" to troubleshoot it yet...
this works: www.mydomain.com/rails and returns my app's view
but this: www.mydomain.com/rails/ returns (in its entirety):
<html>
<body>
Index from public
</body>
</html>
Where is this coming from!?! I've ruled out Apache. as Apache wouldn't return that kind of html as an index of a directory...
Added: VirtualHost (per request):
<VirtualHost *:80>
ServerName www.mydomain.com
ServerAdmin admin#mydomain.com
DocumentRoot "/Library/WebServer/mydomainweb"
DirectoryIndex "index.html" "index.php"
CustomLog "/var/log/apache2/access_log" "%h %l %u %t \"%r\" %>s %b"
ErrorLog "/var/log/apache2/error_log"
ErrorDocument 404 /error.html
<IfModule mod_ssl.c>
SSLEngine Off
SSLCertificateFile "/etc/certificates/Default.crt"
SSLCertificateKeyFile "/etc/certificates/Default.key"
SSLCipherSuite "ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:!SSLv2:+EXP:+eNULL"
</IfModule>
<IfModule mod_dav.c>
DAVLockDB "/var/run/davlocks/.davlock100"
DAVMinTimeout 600
</IfModule>
<IfModule mod_mem_cache.c>
CacheEnable mem /
MCacheSize 4096
</IfModule>
<Directory "/Library/WebServer/mydomainweb">
AllowOverride None
<IfModule mod_dav.c>
DAV On
</IfModule>
Options All -Includes -ExecCGI +MultiViews -Indexes
</Directory>
RailsBaseURI /rails
<Directory /Library/WebServer/rails/myapp/public>
Options -MultiViews -Indexes
</Directory>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]
</IfModule>
<IfModule mod_proxy_balancer.c>
<Proxy "balancer://balancer-group">
</Proxy>
</IfModule>
<IfModule mod_alias.c>
Alias "/collaboration" "/usr/share/collaboration"
Alias "/icons/" "/usr/share/httpd/icons/"
Alias "/error/" "/usr/share/httpd/error/"
Redirect temp "/zapp.html" "/index.html"
</IfModule>
Include /etc/apache2/httpd_groups.conf
Include /etc/apache2/httpd_teams_required.conf
LogLevel warn
ServerAlias mydomain.com
ServerAlias images.mydomain.com
</VirtualHost>
My guess is that apache has directory browsing enabled and passenger is routing this request to the public folder which in turn is going to apache direct.
You can try
Disabling directory browsing by disabling Options Indexes (omitting Indexes)
You possibly catch a route in your routes.rb file to that path explicitly and route it to where you wish.
For the second one, does it work if you do www.mydomain.com/rails/mycontroller/show/1?
If it works with "show" in between mycontroller and 1, there's a problem with your routes.

Resources