aboutsummaryrefslogtreecommitdiff
path: root/config/gitreverseproxy.conf
blob: 4649d21e93310e761f59159cd5594d1469e835e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
######################################
# GitRepository Apache Config
#
#    Reverse proxy traffic to Git Instaweb instances through Apache
#
# Usage:  include this file in your Apache config and invoke it with the following syntax
#
#       Use GitRepositoryHTTP REPONAME SERVER-IP PORT
#       Use GitRepositoryHTTPS REPONAME SERVER-IP PORT
#
#       REPONAME - name of repository (used for defining URL)
#       SERVER-IP - IP address of server where Git Instaweb is running
#       PORT - port number on which the Git Instaweb instance in running
#
# You can set the GitProxyServerName variable in this config to 
# reflect the Apache hostname your running your repos on
#
# This is included in the latest release of giterdun (Git Instaweb Automation).  Check it out at https://github.com/bng44270/giterdun-bash
#
######################################

Define GitProxyServerName localhost.localdomain

<Macro GitRepositoryHTTP $reponame $gitserver $portnum>
  <Location "/$reponame/">
    ProxyPass "http://$gitserver:$portnum/"

    RequestHeader unset Accept-Encoding

    SetOutputFilter INFLATE;SUBSTITUTE;DEFLATE

    Substitute "s|.git</a>|$reponame</a>|in"
    Substitute "s|<title>$gitserver Git|<title>$reponame|in"
    Substitute "s|href=\"/|href=\"http://${GitProxyServerName}/$reponame/|in"
    Substitute "s|src=\"static/|src=\"http://${GitProxyServerName}/$reponame/static/|in"
    Substitute "s|href=\"static/|href=\"http://${GitProxyServerName}/$reponame/static/|in"
    Substitute "s|<a href=\"http://${GitProxyServerName}/$reponame/\">projects</a>|<a href=\"/\">${GitProxyServerName}</a>|in"
  </Location>

  ProxyPassReverse /$reponame/ http://$gitserver:$portnum/

  RewriteEngine On
  RewriteCond %{REQUEST_URI} $reponame$
  RewriteRule ^(.*)$ http://${GitProxyServerName}/$reponame/ [L,R=301]
</Macro>

<Macro GitRepositoryHTTPS $reponame $gitserver $portnum>
  <Location "/$reponame/">
    ProxyPass "http://$gitserver:$portnum/"

    RequestHeader unset Accept-Encoding

    SetOutputFilter INFLATE;SUBSTITUTE;DEFLATE

    Substitute "s|.git</a>|$reponame</a>|in"
    Substitute "s|<title>$gitserver Git|<title>$reponame|in"
    Substitute "s|href=\"/|href=\"https://${GitProxyServerName}/$reponame/|in"
    Substitute "s|src=\"static/|src=\"https://${GitProxyServerName}/$reponame/static/|in"
    Substitute "s|href=\"static/|href=\"https://${GitProxyServerName}/$reponame/static/|in"
    Substitute "s|<a href=\"https://${GitProxyServerName}/$reponame/\">projects</a>|<a href=\"/\">${GitProxyServerName}</a>|in"
  </Location>

  ProxyPassReverse /$reponame/ http://$gitserver:$portnum/

  RewriteEngine On
  RewriteCond %{REQUEST_URI} $reponame$
  RewriteRule ^(.*)$ https://${GitProxyServerName}/$reponame/ [L,R=301]
</Macro>