/
nginx_epa_aws_kube.conf
168 lines (137 loc) · 5.24 KB
/
nginx_epa_aws_kube.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#################################################
# Nginx conf with qed + cyanweb + cyano, #
# where cyano runs outside qed's docker network #
#################################################
# HTTP -> HTTPS Redirect
server {
listen 80;
# Removes Nginx version from headers:
server_tokens off;
return 301 https://$host$request_uri;
}
# qed.epa.gov django front-end HTTPS/SSL
server {
listen 443 ssl default_server;
client_max_body_size 20M;
client_body_buffer_size 20M;
# Allow CORS requests for development purposes, not to be copied to Staging or Production instances.
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, DELETE';
# HSTS Policy (max-age=60 == 1 min. 31536000 = 1 year)
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-XSS-Protection "1; mode=block";
add_header X-Frame-Options "SAMEORIGIN";
# Self-signed cert and key (container locations):
ssl_certificate /etc/letsencrypt/live/ceeopdev.net/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ceeopdev.net/privkey.pem;
ssl_session_timeout 5m;
#disable ssl2 and ssl3 per
#https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
# Diffie-Hellman file:
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
# Removes Nginx version from headers:
server_tokens off;
location /static_qed/ {
alias /src/collected_static/;
}
location /assets/ {
alias /src/collected_static/hms/webapp/assets/;
}
location /hms/assets/ {
alias /src/collected_static/hms/webapp/assets/;
}
location / {
try_files $uri @uwsgi_django;
}
location @uwsgi_django {
include uwsgi_params;
uwsgi_pass uwsgi_django:8080; # 'uwsgi_django' is the hostname given in Docker-Compose YAML 'links' section
proxy_read_timeout 600;
proxy_send_timeout 600;
uwsgi_read_timeout 600s;
uwsgi_send_timeout 600s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# HSTS Policy (max-age=60 == 1 min), 31536000 = 1 year Unknown if proxy_set_header disables inheritance like add_header
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}
# nodejs/socket.io route:
location /socket.io {
proxy_pass http://cts_nodejs:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
}
# Proxy for marvinsketch iframe webservice requests:
location /webservices/rest-v0/util {
proxy_pass http://qed-tomcat:8080/webservices/rest-v0/util;
}
# Proxy for ctsws endpoint:
location /ctsws/rest/isvalidchemical {
proxy_pass http://qed-tomcat:8080/ctsws/rest/isvalidchemical;
}
# Cyanweb prevents env.json caching:
location /cyanweb/assets/env.json {
expires -1;
add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
alias /src/collected_static/epa-cyano-web/assets/env.json;
}
# Cyanweb static content routing:
location /cyanweb/assets {
alias /src/collected_static/epa-cyano-web/assets;
}
location /cyanweb/leaflet {
alias /src/collected_static/epa-cyano-web/leaflet;
}
# Cyanweb API:
location /cyan/app/api {
include /etc/nginx/uwsgi_params;
uwsgi_pass uwsgi_flask:5001;
}
# Cyano API
location /cyan/cyano {
proxy_pass http://172.17.0.1:8080/cyan/cyano; # NOTE: docker host ip (host.docker.internal coming to linux in docker engine v20)
}
# Cyano Admintool
location /admintool {
proxy_pass http://172.17.0.1:8000;
}
# Cyano Admintool Static
location /static {
proxy_pass http://172.17.0.1:8000/static;
}
# Cyano Admintool Media
location /media {
proxy_pass http://172.17.0.1:8000/media;
}
# Cyan-waterbody API
location /waterbody {
proxy_pass http://172.17.0.1:8085/waterbody;
}
}
# Flask back-end
server {
listen 7777;
# HSTS Policy (max-age=60 == 1 min, 31536000 = 1 year)
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
client_max_body_size 20M;
client_body_buffer_size 20M;
location / {
try_files $uri @qed_flask;
}
location @qed_flask {
include uwsgi_params;
uwsgi_pass qed_flask:8080; # 'uwsgi_flask' is the hostname given in Docker-Compose YAML 'links' section
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# HSTS Policy (max-age=60 == 1 min 31536000 = 1 year), Unknown if proxy_set_header disables inheritance like add_header
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
}
}