This repository has been archived by the owner on Feb 14, 2018. It is now read-only.
forked from fecgov/fec-proxy
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
85 lines (74 loc) · 2.57 KB
/
nginx.conf
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
worker_processes 1;
daemon off;
error_log <%= ENV["APP_ROOT"] %>/nginx/logs/error.log;
events { worker_connections 1024; }
http {
log_format cloudfoundry '$http_x_forwarded_for - $http_referer - [$time_local] "$request" $status $body_bytes_sent';
access_log <%= ENV["APP_ROOT"] %>/nginx/logs/access.log cloudfoundry;
default_type application/octet-stream;
include mime.types;
sendfile on;
gzip on;
gzip_disable "msie6";
gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types text/plain text/css text/js text/xml text/javascript application/javascript application/x-javascript application/json application/xml application/xml+rss;
tcp_nopush on;
keepalive_timeout 30;
port_in_redirect off; # Ensure that redirects don't include the internal container PORT - <%= ENV["PORT"] %>
server_tokens off;
server {
listen <%= ENV["PORT"] %>;
server_name localhost;
client_max_body_size 100M; #increase upload size limit
include <%= ENV["APP_ROOT"] %>/public/redirects-www.conf;
<% if File.exists?(auth_file = File.join(ENV["APP_ROOT"], "nginx/conf/.htpasswd")) %>
auth_basic "Restricted";
auth_basic_user_file <%= auth_file %>;
<% end %>
<% require 'json' %>
<% proxies = JSON.parse(ENV["PROXIES"] || "{}") %>
<% proxies.each do |path, route| %>
location <%= path %> {
resolver 8.8.8.8 ipv6=off;
set $backend "<%= route %>";
proxy_pass $backend;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Script-Name "<%= path %>";
add_header Cache-Control "max-age=600";
}
<% end %>
location ~ /resources/(.*) {
resolver 8.8.8.8;
proxy_pass_request_headers off;
proxy_pass <%= ENV["S3_BUCKET_URL"] %>/$1;
}
location ~ /files/(.*) {
resolver 8.8.8.8;
proxy_pass_request_headers off;
proxy_pass <%= ENV["S3_LEGAL_AND_DOWNLOADS_URL"] %>/$1;
}
}
server {
listen <%= ENV["PORT"] %>;
server_name beta.fec.gov;
rewrite ^/(.*)$ https://www.fec.gov/$1 permanent;
}
server {
listen <%= ENV["PORT"] %>;
server_name transition.fec.gov;
include <%= ENV["APP_ROOT"] %>/public/redirects-transition.conf;
location / {
resolver 8.8.8.8;
error_page 404 error.html;
proxy_hide_header x-amz-id-2;
proxy_hide_header x-amz-request-id;
proxy_hide_header x-amz-meta-s3cmd-attrs;
proxy_pass <%= ENV["S3_TRANSITION_URL"] %>$uri;
add_header X-Frame-Options "SAMEORIGIN";
}
}
}