-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservers.conf.erb
99 lines (87 loc) · 2.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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"'<%#
To allow dynamic logging format for nginx,
create a json that contains the key/value pairs
you want to add to nginx logging.
For the logs to be correctly parsed, use the nginx_logger_version parameter.
For example:
ADDITIONAL_NGINX_LOGS='{"nginx_logger_version":"1", "my_custom_header":"$http_my_custom_header"}'
%><%
require 'json';
JSON.parse(ENV['ADDITIONAL_NGINX_LOGS']||'{}').each do |nginx_key,value| %>
' <%= nginx_key %>="<%= value %>"'<% end %>;
# 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;
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;
#
# Token API
#
location /token {
proxy_pass https://<%= ENV["PIX_API_HOSTNAME"] %>/api/application/token;
}
# Deprecated route
location /api/token {
proxy_set_header Deprecation "@1736788266"; # 2025-01-13T17:11:06.000Z
proxy_pass https://<%= ENV["PIX_API_HOSTNAME"] %>/api/application/token;
}
#
# Pole Emploi API
#
location /pole-emploi {
proxy_pass https://<%= ENV["PIX_API_HOSTNAME"] %>/api/pole-emploi;
}
#
# LSU API
#
location /organizations {
proxy_pass https://<%= ENV["PIX_API_HOSTNAME"] %>/api/organizations;
}
#
# Healthcheck
#
location /healthcheck {
proxy_pass https://<%= ENV["PIX_API_HOSTNAME"] %>/api/healthcheck/db;
}
#
# Parcoursup
#
location /parcoursup/ {
proxy_pass https://<%= ENV["PIX_API_HOSTNAME"] %>/api/application/parcoursup/;
}
#
# Open API documentation
#
location ~ ^/documentation/(.*)?$ {
proxy_pass https://<%= ENV["PIX_API_HOSTNAME"] %>/documentation/$1;
}
add_header X-Content-Type-Options "nosniff";
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection 1;
<% 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 %>
}