Content
installation in http-subdirectory: compiled css assets contain wrong url
Added by Jonas Küpper over 11 years ago
hi,
i have installed openproject on a CentOS server in /home/openproject/openproject to be served via apache/passenger in a subdirectory like this: http://1.2.3.4/openproject
with a litlle fiddling i made it work with the suggestions from https://www.openproject.org/topics/1340 and https://www.phusionpassenger.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri.
This let me run openproject through the subdirectory, however the generated css files contain wrong paths to the web assets like fonts and images. For example
default-[HASH].css is correctly loaded through http://1.2.3.4/openproject/assets/default-[HASH].css but it contains this CSS:
@font-face{
font-family:"LatoLight";
src:url(/assets/lato/Lato-Lig-webfont-ce304c9c1de225bd631232a7050644b9.eot);
src:
url(/assets/lato/Lato-Lig-webfont.eot?#iefix) format("embedded-opentype"),
url(/assets/lato/Lato-Lig-webfont-91b91c476db37a67760fa2947f741196.ttf) format("truetype"),
url(/assets/lato/Lato-Lig-webfont.svg#untitled-font-1) format("svg"),
url(/assets/lato/Lato-Lig-webfont-8da994d0cd00558a03e543da3bec79d7.woff) format("woff");
font-weight:normal;
font-style:normal}
where it would map to http://1.2.3.4/assets/lato/Lato-Lig-webfont.eot?#iefix which does not exist.
with a subdirectory deployment this should either be a relative URL like url(lato/Lato-Lig-webfont-ce304c9c1de225bd631232a7050644b9.eot) or url(/openproject/assets/lato/Lato-Lig-webfont-ce304c9c1de225bd631232a7050644b9.eot).
for my first try i hadn’t set rails_relative_url_root: "/openproject" in configuration.yml but even after i changed the config and executed RAILS_ENV="production" bundle exec rake assets:precompile that didn’t change. i even moved the whole public/assets-folder somewhere else and let it recompile, to no avail.
I managed to fix it by setting an alias in the apache config:
Alias /assets /home/openproject/openproject/public/assets
but i rather would see openproject to be contained in the http://1.2.3.4/openproject-subdirectory
do i miss something here? is there any way to fix the paths during css compilation??
Replies (3)
Hello Jonas,
it should be enough to set
rails_relative_url_rootin configuration.yml before you precompile the assets and set thePassengerBaseURIin your apache config.Do you run the latest stable version (3.0.8) of OpenProject?
Best
Ratzi
yes its openproject 3.0.8 (checked out two days ago). as i said, i already set that variable. why would the apache config have influence on the compiling of the assets?
anyway, i just did that:
[openproject@devtest openproject]$ pwd /home/openproject/openproject [openproject@devtest openproject]$ grep -C 3 rails_relative_url_root config/configuration.yml # For OpenProject to be reachable as # https://example.org/open_project # the setting has o be: rails_relative_url_root: "/openproject" # # rails_relative_url_root: "" # Absolute path to the directory where attachments are stored. # The default is the 'files' directory in your OpenProject instance. [openproject@devtest openproject]$ cat /etc/httpd/conf.d/openproject.conf LoadModule passenger_module /home/openproject/.rvm/gems/ruby-2.1.0/gems/passenger-4.0.46/buildout/apache2/mod_passenger.so <IfModule mod_passenger.c> PassengerRoot /home/openproject/.rvm/gems/ruby-2.1.0/gems/passenger-4.0.46 PassengerDefaultRuby /home/openproject/.rvm/gems/ruby-2.1.0/wrappers/ruby </IfModule> Alias /openproject /home/openproject/openproject/public Alias /assets /home/openproject/openproject/public/assets <Location /openproject> PassengerBaseURI /openproject PassengerAppRoot /home/openproject/openproject RackBaseURI /openproject </Location> <Directory /home/openproject/openproject/public> # This relaxes Apache security settings. AllowOverride all # MultiViews must be turned off. Options -MultiViews Order Allow,Deny Allow from all </Directory> [openproject@devtest openproject]$ ls -l public/assets/default*.css -rw-rw-r--. 1 openproject openproject 189578 Jul 15 18:23 public/assets/default-a4064ba5ece15134721e8e4c5e99c39d.css -rw-rw-r--. 1 openproject openproject 185816 Jul 15 18:23 public/assets/default.css [openproject@devtest openproject]$ head -c 150 public/assets/default-a4064ba5ece15134721e8e4c5e99c39d.css ; echo @font-face{font-family:"LatoLight";src:url(/assets/lato/Lato-Lig-webfont-ce304c9c1de225bd631232a7050644b9.eot);src:url(/assets/lato/Lato-Lig-webfont.e [openproject@devtest openproject]$ RAILS_ENV="production" bundle exec rake assets:precompile require 'rails/all'... 0.290s Bundler.require... 0.780s /home/openproject/.rvm/rubies/ruby-2.1.0/bin/ruby /home/openproject/.rvm/rubies/ruby-2.1.0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets require 'rails/all'... 0.270s Bundler.require... 0.790s Application.initialize!... [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. 1.690s require 'rails/all'... 0.280s Bundler.require... 0.780s Application.initialize!... [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. 1.650s [openproject@devtest openproject]$ ls -l public/assets/default*.css -rw-rw-r--. 1 openproject openproject 189578 Jul 15 18:23 public/assets/default-a4064ba5ece15134721e8e4c5e99c39d.css -rw-rw-r--. 1 openproject openproject 185816 Jul 15 18:23 public/assets/default.css [openproject@devtest openproject]$ head -c 150 public/assets/default-a4064ba5ece15134721e8e4c5e99c39d.css ; echo @font-face{font-family:"LatoLight";src:url(/assets/lato/Lato-Lig-webfont-ce304c9c1de225bd631232a7050644b9.eot);src:url(/assets/lato/Lato-Lig-webfont.eSo no change.
i even tried to move the assets folder out of the way, no success:
[openproject@devtest openproject]$ mv public/assets/ assets_old [openproject@devtest openproject]$ RAILS_ENV="production" bundle exec rake assets:precompile require 'rails/all'... 0.290s Bundler.require... 0.780s /home/openproject/.rvm/rubies/ruby-2.1.0/bin/ruby /home/openproject/.rvm/rubies/ruby-2.1.0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets require 'rails/all'... 0.270s Bundler.require... 0.780s Application.initialize!... [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. 1.630s require 'rails/all'... 0.280s Bundler.require... 0.750s Application.initialize!... [deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message. 1.620s [openproject@devtest openproject]$ ls -l public/assets/default*.css -rw-rw-r--. 1 openproject openproject 189578 Jul 15 18:23 public/assets/default-a4064ba5ece15134721e8e4c5e99c39d.css -rw-rw-r--. 1 openproject openproject 185816 Jul 15 18:23 public/assets/default.css [openproject@devtest openproject]$ head -c 150 public/assets/default-a4064ba5ece15134721e8e4c5e99c39d.css ; echo @font-face{font-family:"LatoLight";src:url(/assets/lato/Lato-Lig-webfont-ce304c9c1de225bd631232a7050644b9.eot);src:url(/assets/lato/Lato-Lig-webfont.eAs the modification time of the css files do not change i guess they are simply copied from somewhere without processing?
Hi
I think Ratzi just supplied the answer in
https://www.openproject.org/topics/1340
the change should be
rails_relative_url_root: “/public”
I just removed the work around and tested it and it worked
:)
have updated my doco
thanks Ratzi