-
Notifications
You must be signed in to change notification settings - Fork 57
/
servers.conf.erb
61 lines (49 loc) · 1.58 KB
/
servers.conf.erb
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
log_format keyvalue
'method=$request_method'
' path="$request_uri"'
' host=$host'
' request_id=$http_x_request_id'
' from="$remote_addr"'
' protocol=$scheme'
' status=$status'
' duration=${request_time}s'
' bytes=$bytes_sent'
' referer="$http_referer"'
' user_agent="$http_user_agent"';
# In order to avoid logging access twice per request
# it is necessary to turn off the top-level (e.g. http) buildpack default access_log
# as we are about to override it in the server directive here below
access_log off;
#add a catch all on http port to forward to the convenient https
server {
listen 80 default_server;
server_name _;
add_header Strict-Transport-Security "max-age=31536001; includeSubDomains; preload";
return 301 https://$host$request_uri;
}
server {
access_log logs/access.log keyvalue;
server_name localhost;
listen <%= ENV['PORT'] %>;
charset utf-8;
# Disable compression that is performed by the Scalingo router anyway
gzip off;
location ~ ^/(?<app>[^/]+)/.*$ {
root /app/dist/;
try_files $uri /$app/index.html =404;
expires -1;
}
add_header X-Content-Type-Options "nosniff";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection 1;
add_header Strict-Transport-Security "max-age=31536001; includeSubDomains; preload";
<% ENV.each do |key,value|
if key.start_with? 'ADD_HTTP_HEADER' %>
add_header <%=
key.sub(/^ADD_HTTP_HEADER_/, '').split("_").map(&:capitalize).join("-")
%> "<%=
value.gsub('\\', '\\\\\\\\').gsub('"','\\"').gsub('$','\\$')
%>" ;
<% end
end %>
}