Top Menu

Jump to content
Home
    Modules
      • Projects
      • Activity
      • Work packages
      • Gantt charts
      • Calendars
      • Team planners
      • Boards
      • News
    • Getting started
    • Introduction video
      Welcome to OpenProject Community
      Get a quick overview of project management and team collaboration with OpenProject. You can restart this video from the help menu.

    • Help and support
    • Upgrade to Enterprise edition
    • User guides
    • Videos
    • Shortcuts
    • Community forum
    • Enterprise support

    • Additional resources
    • Data privacy and security policy
    • Digital accessibility (DE)
    • OpenProject website
    • Security alerts / Newsletter
    • OpenProject blog
    • Release notes
    • Report a bug
    • Development roadmap
    • Add and edit translations
    • API documentation
  • Sign in
      Forgot your password?

      or sign in with your existing account

      Google

Side Menu

  • Overview
  • Activity
    Activity
  • Roadmap
  • Work packages
    Work packages
  • Gantt charts
    Gantt charts
  • Calendars
    Calendars
  • Team planners
    Team planners
  • Boards
    Boards
  • News
  • Forums

Content

Support Installation & Updates
  1. OpenProject
  2. Forums
  3. Support Installation & Updates
  4. installation in http-subdirectory: compiled css assets contain wrong url

installation in http-subdirectory: compiled css assets contain wrong url

Added by Jonas Küpper almost 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)

RE: installation in http-subdirectory: compiled css assets contain wrong url - Added by Christian Ratz almost 11 years ago

Hello Jonas,

it should be enough to set rails_relative_url_root in configuration.yml before you precompile the assets and set the PassengerBaseURI in your apache config.

Do you run the latest stable version (3.0.8) of OpenProject?

Best
Ratzi

RE: installation in http-subdirectory: compiled css assets contain wrong url - Added by Jonas Küpper almost 11 years ago

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.e

So 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.e

As the modification time of the css files do not change i guess they are simply copied from somewhere without processing?

RE: installation in http-subdirectory: compiled css assets contain wrong url - Added by Brendan Dunn over 10 years ago

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

  • (1 - 3/3)
Loading...