Skip to content

Commit

Permalink
Add http2 support for apache/nginx (rt#5957)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvperrin committed Jan 21, 2019
1 parent 3602634 commit 9b75c22
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 12 deletions.
4 changes: 4 additions & 0 deletions modules/ocf/manifests/nginx_proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
$ssl_key = "/etc/ssl/private/${::fqdn}.key",
$ssl_dhparam = '/etc/ssl/dhparam.pem',

$http2 = $ssl,

# Accept any other arbitrary options passed in and pass them on to
# nginx::resource::server
$nginx_options = {},
Expand All @@ -33,6 +35,7 @@
proxy_set_header => concat($base_headers, $proxy_set_header),

listen_port => 443,
http2 => $http2,
ssl => true,
ssl_cert => $ssl_cert,
ssl_key => $ssl_key,
Expand Down Expand Up @@ -63,6 +66,7 @@
},

listen_port => 443,
http2 => true,
ssl => true,
ssl_cert => $ssl_cert,
ssl_key => $ssl_key,
Expand Down
21 changes: 12 additions & 9 deletions modules/ocf_apphost/files/vhost-app.jinja
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# {{vhost.comment}}
server {
listen {{vhost.port}};
listen [::]:{{vhost.port}};
server_name "{{vhost.fqdn}}";

{% if vhost.ssl %}
listen {{vhost.port}} ssl http2;
listen [::]:{{vhost.port}} ssl http2;

ssl_certificate {{vhost.ssl.bundle}};
ssl_certificate_key {{vhost.ssl.key}};
add_header Strict-Transport-Security "max-age=31536000";
{% else %}
listen {{vhost.port}};
listen [::]:{{vhost.port}};
{% endif %}

location /.well-known/ {
alias /var/lib/lets-encrypt/.well-known/;
}
Expand All @@ -26,11 +36,4 @@ server {
}

access_log /var/log/nginx/vhost_access.log vhost;

{% if vhost.ssl %}
ssl on;
ssl_certificate {{vhost.ssl.bundle}};
ssl_certificate_key {{vhost.ssl.key}};
add_header Strict-Transport-Security "max-age=31536000";
{% endif %}
}
5 changes: 2 additions & 3 deletions modules/ocf_apphost/templates/default-vhost.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ server {

# HTTPS default vhost
server {
listen 443 default_server;
listen [::]:443 default_server;
listen 443 default_server ssl http2;
listen [::]:443 default_server ssl http2;
server_name apphost.ocf.berkeley.edu;

ssl on;
ssl_certificate /etc/ssl/private/<%= @fqdn %>.bundle;
ssl_certificate_key /etc/ssl/private/<%= @fqdn %>.key;

Expand Down
1 change: 1 addition & 0 deletions modules/ocf_docker/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
nginx::resource::server {
default:
listen_port => 443,
http2 => true,

ssl => true,
ssl_cert => "/etc/ssl/private/${::fqdn}.bundle",
Expand Down
1 change: 1 addition & 0 deletions modules/ocf_mesos/manifests/master/webui.pp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
manage_repo => false,
confd_purge => true,
server_purge => true,
http2 => true,
nginx_cfg_prepend => {
'load_module' => '"modules/ngx_http_auth_pam_module.so"',
},
Expand Down
6 changes: 6 additions & 0 deletions modules/ocf_mirrors/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
include apache::mod::headers
include apache::mod::status

# Support http2 (rt#5957)
apache::mod { 'http2':; }
apache::custom_config { 'http2':
content => "Protocols h2 http/1.1\n",
}

# Restart apache if any cert changes occur
Class['ocf::ssl::default'] ~> Class['Apache::Service']

Expand Down
1 change: 1 addition & 0 deletions modules/ocf_ssh/manifests/webssh.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
manage_repo => false,
confd_purge => true,
server_purge => true,
http2 => true,
}

# Restart nginx if any cert changes occur
Expand Down
8 changes: 8 additions & 0 deletions modules/ocf_www/manifests/mod/http2.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ocf_www::mod::http2 {
# Support http2 (rt#5957)
apache::mod { 'http2':; }

apache::custom_config { 'http2':
content => "Protocols h2 http/1.1\n",
}
}
1 change: 1 addition & 0 deletions modules/ocf_www/manifests/site/www.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
include apache::mod::status
include ocf_www::mod::cgi
include ocf_www::mod::fcgid
include ocf_www::mod::http2
include ocf_www::mod::ocfdir
include ocf_www::mod::php
include ocf_www::mod::suexec
Expand Down

0 comments on commit 9b75c22

Please sign in to comment.