Skip to content

Instantly share code, notes, and snippets.

@uebayasi
Last active August 29, 2015 14:12
Show Gist options
  • Select an option

  • Save uebayasi/89dc40ce8b2625b9ef03 to your computer and use it in GitHub Desktop.

Select an option

Save uebayasi/89dc40ce8b2625b9ef03 to your computer and use it in GitHub Desktop.
  • Summary

    • Installing Redmine under sub-URI is hard
    • Input
      • Make Apache access localhost:3000/redmine
        • ProxyPass /redmine http://localhost:3000/redmine
      • Make Redmine process /redmine
        • Dynamic contents -> routing
          • Edit config/routes.rb
        • Static contents -> ???
          • XXX Doesn't work
          • XXX XXX XXX Let Apache redirect static requests
    • Output
      • Make Redmine append /redmine sub-URI
        • Pass unicorn --path /redmine
      • Make Apache return example.com/redmine
        • ProxyPassReverse /redmine http://localhost:3000/redmine
  • Running Redmine in localhost:3000

    • Edit unicorn.sh:
pkill unicorn
path="--path /redmine"
envs="-E production"
conf="-c config/unicorn.rb"
port="-p 3000"

bundle exec unicorn_rails -D $path $conf $envs $port
  • Run unicorn.sh
  • Check:
% curl -s http://localhost:3000/redmine/ | head -20
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Redmine</title>
<meta name="description" content="Redmine" />
<meta name="keywords" content="issue,bug,tracker" />
<meta content="authenticity_token" name="csrf-param" />
<meta content="Aq+mQ7yx8jhmJGbH4z/e8zm8iaC/F4iBGgkABmoor78=" name="csrf-token" />
<link rel='shortcut icon' href='/redmine/favicon.ico?1413918791' />
<link href="/redmine/stylesheets/jquery/jquery-ui-1.11.0.css?1413918791" media="all" rel="stylesheet" type="text/css" />
<link href="/redmine/stylesheets/application.css?1413918791" media="all" rel="stylesheet" type="text/css" />
 
<script src="/redmine/javascripts/jquery-1.11.1-ui-1.11.0-ujs-3.1.1.js?1413918791" type="text/javascript"></script>
<script src="/redmine/javascripts/application.js?1413918791" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
$(window).load(function(){ warnLeavingUnsaved('The current page contains unsaved text that will be lost if you leave this page.'); });
//]]>
</script>
  • Apache
    • Redirect static contents:
<VirtualHost *:443>
  :
    ProxyPass /redmine/help/ !
    ProxyPass /redmine/images/ !
    ProxyPass /redmine/javascripts/ !
    ProxyPass /redmine/plugin_assets/ !
    ProxyPass /redmine/stylesheets/ !
    ProxyPass /redmine/themes/ !

    Alias /redmine/help/ /var/www/redmine/public/help/
    Alias /redmine/images/ /var/www/redmine/public/images/
    Alias /redmine/javascripts/ /var/www/redmine/public/javascripts/
    Alias /redmine/plugin_assets/ /var/www/redmine/public/plugin_assets/
    Alias /redmine/stylesheets/ /var/www/redmine/public/stylesheets/
    Alias /redmine/themes/ /var/www/redmine/public/themes/
  :
</VirtualHost>
  • Redirect dynamic contents:
<VirtualHost *:443>
  :
    ProxyPass /redmine/ http://localhost:3000/redmine/
    ProxyPassReverse /redmine/ http://localhost:3000/redmine/
  :
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment