summaryrefslogtreecommitdiff
path: root/sitemodules/profiles/templates/nginx_revproxy/virtual_host.nginx.epp
blob: 38409cf2b2b7772cb8f907b876048c9954662ff7 (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
<%- | String $virtual_host,
      String $target,
      String $custom_config,
| -%>
# THIS FILE IS MANAGED BY PUPPET, MANUAL CHANGES WILL BE OVERWRITTEN AT THE
# NEXT PUPPET RUN.

server {
  listen 80;
  listen [::]:80;

  listen 443 ssl;
  listen [::]:443 ssl;

  if ($https != "on") {
    return 301 https://$host$uri;
  }

  ssl_certificate /etc/ssl/public/<%= $virtual_host %>.chain.pem;
  ssl_certificate_key /etc/ssl/private/<%= $virtual_host %>.key.pem;

  access_log /var/log/nginx/<%= $virtual_host %>.access.log;
  error_log /var/log/nginx/<%= $virtual_host %>.error.log;

  server_name <%= $virtual_host %>;
  <%= $custom_config -%>

  location / {
    proxy_pass       <%= $target %>;
    proxy_set_header X-Forwarded-Host   $host:$server_port;
    proxy_set_header X-Forwarded-Server $host;
    proxy_set_header Host               $host;
    proxy_set_header X-Real-IP          $remote_addr;
    proxy_set_header X-Forwarded-For    $proxy_add_x_forwarded_for;
  }
}