Skip to content

Commit 4caa94d

Browse files
authored
Merge pull request #316 from antaflos/additional_connectors
Allow defining additional Tomcat connectors
2 parents a7bd419 + 52e1796 commit 4caa94d

8 files changed

Lines changed: 270 additions & 9 deletions

File tree

README.md

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,23 @@ Password to access java keystore. Defaults to 'changeit'
514514

515515
Defaults to 'JKS'. Valid options are 'JKS', 'PKCS12', 'JCEKS'.
516516

517+
##### `$tomcat_additional_connectors`
518+
519+
Well-formed, complex Hash where each key represents a port number and the key's
520+
value is a hash whose key/value pairs represent the attributes and their values
521+
that define the connector's behaviour. Default is `{}`.
522+
523+
Use this parameter to specify arbitrary, additional connectors with arbitrary
524+
attributes. There are no defaults here, so you must take care to specify all
525+
attributes a connector requires to work in Jira. See below for examples.
526+
527+
This is useful if you need to access your Jira instance directly through an
528+
additional HTTP port, e.g. one that is not configured for reverse proxy use.
529+
Atlassian describes use cases for this in
530+
https://confluence.atlassian.com/kb/how-to-create-an-unproxied-application-link-719095740.html
531+
and
532+
https://confluence.atlassian.com/kb/how-to-bypass-a-reverse-proxy-or-ssl-in-application-links-719095724.html
533+
517534
#### Crowd single sign on parameters
518535

519536
#### `enable_sso`
@@ -562,15 +579,53 @@ Some more crowd.properties for SSO, see atlassian documentation for details
562579

563580
```puppet
564581
class { 'jira':
565-
version => '6.0.1',
566-
installdir => '/opt/atlassian-jira',
567-
homedir => '/opt/atlassian-jira/jira-home',
568-
user => 'jira',
569-
group => 'jira',
570-
dbpassword => 'secret',
571-
dbserver => 'localhost',
572-
javahome => '/opt/java/jdk1.7.0_21/',
573-
download_url => 'http://myserver/pub/development-tools/atlassian/',
582+
version => '6.0.1',
583+
installdir => '/opt/atlassian-jira',
584+
homedir => '/opt/atlassian-jira/jira-home',
585+
user => 'jira',
586+
group => 'jira',
587+
dbpassword => 'secret',
588+
dbserver => 'localhost',
589+
javahome => '/opt/java/jdk1.7.0_21/',
590+
download_url => 'http://myserver/pub/development-tools/atlassian/',
591+
tomcat_additional_connectors => {
592+
# Define two additional connectors, listening on port 8081 and 8082
593+
8081 => {
594+
'relaxedPathChars' => '[]|',
595+
'relaxedQueryChars' => '[]|{}^\`"<>',
596+
'maxThreads' => '150',
597+
'minSpareThreads' => '25',
598+
'connectionTimeout' => '20000',
599+
'enableLookups' => 'false',
600+
'maxHttpHeaderSize' => '8192',
601+
'protocol' => 'HTTP/1.1',
602+
'useBodyEncodingForURI' => 'true',
603+
'redirectPort' => '8443',
604+
'acceptCount' => '100',
605+
'disableUploadTimeout' => 'true',
606+
'bindOnInit' => 'false',
607+
},
608+
# This additional connector is configured for access from a reverse proxy
609+
8082 => {
610+
'relaxedPathChars' => '[]|',
611+
'relaxedQueryChars' => '[]|{}^\`"<>',
612+
'maxThreads' => '150',
613+
'minSpareThreads' => '25',
614+
'connectionTimeout' => '20000',
615+
'enableLookups' => 'false',
616+
'maxHttpHeaderSize' => '8192',
617+
'protocol' => 'HTTP/1.1',
618+
'useBodyEncodingForURI' => 'true',
619+
'redirectPort' => '8443',
620+
'acceptCount' => '100',
621+
'disableUploadTimeout' => 'true',
622+
'bindOnInit' => 'false',
623+
'proxyName' => 'jira2.example.com',
624+
'proxyPort' => '443',
625+
'scheme' => 'https',
626+
'secure' => true,
627+
},
628+
}
574629
}
575630
```
576631

@@ -611,6 +666,21 @@ jira::proxy:
611666
proxyName: 'jira.example.co.za'
612667
proxyPort: '443'
613668
jira::contextpath: '/jira'
669+
jira::tomcat_additional_connectors:
670+
8181:
671+
relaxedPathChars: '[]|'
672+
relaxedQueryChars: '[]|{}^\`"<>'
673+
maxThreads: '150'
674+
minSpareThreads: '25'
675+
connectionTimeout: '20000'
676+
enableLookups: 'false'
677+
maxHttpHeaderSize: '8192'
678+
protocol: 'HTTP/1.1'
679+
useBodyEncodingForURI: 'true'
680+
redirectPort: '8443'
681+
acceptCount: '100'
682+
disableUploadTimeout: 'true'
683+
bindOnInit: 'false'
614684
```
615685
616686
These additional and substituted parameters are used in production in an

manifests/init.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@
141141
Hash $proxy = {},
142142
# Options for the AJP connector
143143
Hash $ajp = {},
144+
# Additional connectors in server.xml
145+
Jira::Tomcat_connectors $tomcat_additional_connectors = {},
144146
# Context path (usualy used in combination with a reverse proxy)
145147
String $contextpath = '',
146148
# Resources for context.xml

spec/classes/jira_config_spec.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,53 @@
401401
end
402402
end
403403

404+
context 'tomcat additional connectors' do
405+
let(:params) do
406+
{
407+
version: '6.3.4a',
408+
javahome: '/opt/java',
409+
tomcat_additional_connectors: {
410+
8081 => {
411+
'URIEncoding' => 'UTF-8',
412+
'connectionTimeout' => '20000',
413+
'protocol' => 'HTTP/1.1',
414+
'proxyName' => 'foo.example.com',
415+
'proxyPort' => '8123',
416+
'secure' => true,
417+
'scheme' => 'https'
418+
},
419+
8082 => {
420+
'URIEncoding' => 'UTF-8',
421+
'connectionTimeout' => '20000',
422+
'protocol' => 'HTTP/1.1',
423+
'proxyName' => 'bar.example.com',
424+
'proxyPort' => '8124',
425+
'scheme' => 'http'
426+
}
427+
}
428+
}
429+
end
430+
431+
it do
432+
is_expected.to contain_file('/opt/jira/atlassian-jira-6.3.4a-standalone/conf/server.xml').
433+
with_content(%r{<Connector port="8081"}).
434+
with_content(%r{connectionTimeout="20000"}).
435+
with_content(%r{protocol="HTTP/1\.1"}).
436+
with_content(%r{proxyName="foo\.example\.com"}).
437+
with_content(%r{proxyPort="8123"}).
438+
with_content(%r{scheme="https"}).
439+
with_content(%r{secure="true"}).
440+
with_content(%r{URIEncoding="UTF-8"}).
441+
with_content(%r{<Connector port="8082"}).
442+
with_content(%r{connectionTimeout="20000"}).
443+
with_content(%r{protocol="HTTP/1\.1"}).
444+
with_content(%r{proxyName="bar\.example\.com"}).
445+
with_content(%r{proxyPort="8124"}).
446+
with_content(%r{scheme="http"}).
447+
with_content(%r{URIEncoding="UTF-8"})
448+
end
449+
end
450+
404451
context 'tomcat access log format' do
405452
let(:params) do
406453
{
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
require 'spec_helper'
2+
3+
describe 'Jira::Tomcat_attributes' do
4+
describe 'valid attributes' do
5+
[
6+
{ 'URIEncoding' => 'UTF-8' },
7+
{ 'secure' => true },
8+
{ 'proxyPort' => 8443 },
9+
{
10+
'URIEncoding' => 'UTF-8',
11+
'connectionTimeout' => '20000',
12+
'protocol' => 'HTTP/1.1',
13+
'proxyName' => 'foo.example.com',
14+
'proxyPort' => '8123',
15+
'secure' => true,
16+
'scheme' => 'https'
17+
},
18+
{}
19+
].each do |value|
20+
describe value.inspect do
21+
it { is_expected.to allow_value(value) }
22+
end
23+
end
24+
end
25+
26+
describe 'invalid attributes' do
27+
context 'with garbage inputs' do
28+
[
29+
{ %w[foo blah] => 'bar' },
30+
{ true => 'false' },
31+
{ 'proxyPort' => %w[8443 1234] },
32+
{ 'schema' => { 'https' => 'false' } },
33+
true,
34+
false,
35+
:keyword,
36+
nil,
37+
%w[yes no],
38+
'',
39+
'ネット',
40+
'55555',
41+
'0x123',
42+
'yess',
43+
'nooo'
44+
].each do |value|
45+
describe value.inspect do
46+
it { is_expected.not_to allow_value(value) }
47+
end
48+
end
49+
end
50+
end
51+
end
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
require 'spec_helper'
2+
3+
describe 'Jira::Tomcat_connectors' do
4+
describe 'valid connector specifications' do
5+
[
6+
{
7+
8081 => {
8+
'URIEncoding' => 'UTF-8',
9+
'connectionTimeout' => '20000',
10+
'protocol' => 'HTTP/1.1',
11+
'proxyName' => 'foo.example.com',
12+
'proxyPort' => '80',
13+
'secure' => false,
14+
'scheme' => 'http'
15+
},
16+
8443 => {
17+
'URIEncoding' => 'UTF-8',
18+
'connectionTimeout' => '20000',
19+
'protocol' => 'HTTP/1.1',
20+
'proxyName' => 'foo.example.com',
21+
'proxyPort' => '443',
22+
'secure' => true,
23+
'scheme' => 'https'
24+
}
25+
}
26+
].each do |value|
27+
describe value.inspect do
28+
it { is_expected.to allow_value(value) }
29+
end
30+
end
31+
end
32+
33+
describe 'invalid connector specifications' do
34+
context 'with garbage inputs' do
35+
[
36+
{
37+
'8081' => {
38+
'URIEncoding' => 'UTF-8',
39+
'connectionTimeout' => '20000',
40+
'protocol' => 'HTTP/1.1',
41+
'proxyName' => 'foo.example.com',
42+
'proxyPort' => '80',
43+
'secure' => false,
44+
'scheme' => 'http'
45+
}
46+
},
47+
{
48+
1023 => {
49+
'URIEncoding' => 'UTF-8',
50+
'connectionTimeout' => '20000',
51+
'protocol' => 'HTTP/1.1',
52+
'proxyName' => 'foo.example.com',
53+
'proxyPort' => '80',
54+
'secure' => false,
55+
'scheme' => 'http'
56+
}
57+
},
58+
{ %w[foo blah] => 'bar' },
59+
{ true => 'false' },
60+
{ 'proxyPort' => %w[8443 1234] },
61+
{ 'schema' => { 'https' => 'false' } },
62+
true,
63+
false,
64+
:keyword,
65+
nil,
66+
%w[yes no],
67+
'',
68+
'ネット',
69+
'55555',
70+
'0x123',
71+
'yess',
72+
'nooo'
73+
].each do |value|
74+
describe value.inspect do
75+
it { is_expected.not_to allow_value(value) }
76+
end
77+
end
78+
end
79+
end
80+
end

templates/server.xml.erb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@
119119
/>
120120
<% end -%>
121121

122+
<% if @tomcat_additional_connectors and ! @tomcat_additional_connectors.empty? -%>
123+
<% @tomcat_additional_connectors.sort.map do |port, attrs| -%>
124+
<Connector port="<%= port -%>"
125+
<% attrs.sort.map do |key, value| -%>
126+
<%= key -%>="<%= value -%>"
127+
<% end -%>
128+
/>
129+
<% end -%>
130+
<% end -%>
122131
<Engine name="Catalina" defaultHost="localhost">
123132
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
124133

types/tomcat_attributes.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Jira::Tomcat_attributes = Hash[String[1], Scalar]

types/tomcat_connectors.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
type Jira::Tomcat_connectors = Hash[Stdlib::Port::Unprivileged, Jira::Tomcat_attributes]

0 commit comments

Comments
 (0)