Manager ManagerURL Prefix (sub-uri) server configuration

Author: Manager Manager Displayed: 8077
Created: 27/02/2019 Updated: 09/04/2020
Version: 2
Tags:
MoreLess

Introduction

In most cases, Easy Redmine is run on a subdomain (e.g. https://redmine.mycompany.com). This is the most stable way.

However, due to internal policies, some companies run it on a sub-uri (e.g. https://mycompany.com/redmine). If this is your case, you need to be extra careful about the server configuration. Here are our tips for correct functioning.

Using incorrect configuration may result in problems with some functions. Most notably: Exports, Javascript components like Gantt or WBS, modal windows and others.

This guidline is based on original Redmine (http://www.redmine.org/projects/redmine/wiki/HowTo_Install_Redmine_in_a_sub-URI#Using-RedmineUtils-preferred-solution)

The sample configuration is for application https://prefix.easyredmine.com/redmine

Setup puma

For puma you need to edit 2 files - config.ru and config/environment.rb

config.ru -> add map for "/redmine" around current run application
map  '/redmine' do
  run RedmineApp::Application
end
config/puma.rb -> set RAILS_RELATIVE_URL_ROOT env variable
RAILS_ENV = ENV['RAILS_ENV']
ENV['RAILS_RELATIVE_URL_ROOT'] = '/redmine'

workers 2
threads 1, 2

preload_app!

rackup      DefaultRackup
environment RAILS_ENV || 'production'
plugin "tmp_restart"

worker_timeout 600

APP_HOME = File.join(File.absolute_path(File.dirname(__FILE__)), "../")

directory File.join(APP_HOME, 'public_html')
bind "unix://#{APP_HOME}/application.sock"
pidfile File.join(APP_HOME, 'application.pid')

stdout_redirect File.join(APP_HOME, 'public_html/log/puma.log'), File.join(APP_HOME, 'public_html/log/puma.err')

on_worker_boot do
  ActiveRecord::Base.establish_connection
end

Nginx

Update root, add location for "/redmine" and create aliases. Example:

upstream prefix.easyredmine.com {
  server                      unix:///home/easyproject/prefix.easyredmine.com/application.sock;
}

server {

  listen                      443 ssl http2;
  server_name                 prefix.easyredmine.com;
#  root                        /home/easyproject/prefix.easyredmine.com/public_html/public;
  root                        /home/easyproject/prefix.easyredmine.com/redmine;



  access_log                  /var/log/nginx/prefix.easyredmine.com.log;
  error_log                   /var/log/nginx/prefix.easyredmine.com.err;


location /redmine {
#    root                        /home/easyproject/prefix.easyredmine.com/public_html/public;
    alias                        /home/easyproject/prefix.easyredmine.com/redmine;
    proxy_pass                http://prefix.easyredmine.com;
    include default.d/upstream.conf;
  }

  location /cable {
    proxy_pass                http://prefix.easyredmine.com;
    include default.d/websocket.conf;
  }

location ~ ^/redmine/(images|system|assets|plugin_assets)/ {
    alias                        /home/easyproject/prefix.easyredmine.com/redmine;
    proxy_pass                http://prefix.easyredmine.com;

    gzip_static               on;
    expires                   3M;
    add_header                Cache-Control public;
    add_header                ETag '';
    break;
}

  ssl_certificate             /etc/nginx/ssl/easyredmine_com.crt;
  ssl_certificate_key         /etc/nginx/ssl/easyredmine_com.key;

}

Apache2

    <Directory /path/to/redmine/>                
            RailsBaseURI /redmine
            PassengerResolveSymlinksInDocumentRoot on
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

Don't forget!

In the application settings, enter the full URL.

Administration >> Settings >> General - Host name and path

Image20190227155216_1.png

Add picture from clipboard