Skip to content

Commit 6e401b5

Browse files
committed
Add Content-Security-Policy on nginx.conf.erb
It allows us to share the header between Rust and FastBoot server.
1 parent 728f1d2 commit 6e401b5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

config/nginx.conf.erb

+19
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
<%
2+
def s3_host(env)
3+
cdn = env['S3_CDN']
4+
if cdn and !cdn.empty?
5+
return cdn
6+
end
7+
8+
region = env['S3_REGION']
9+
bucket = env['S3_BUCKET']
10+
11+
unless region.empty?
12+
region = "-#{region}"
13+
end
14+
15+
return "#{bucket}.s3#{region}.amazonaws.com"
16+
end
17+
%>
18+
119
daemon off;
220
#Heroku dynos have at least 4 cores.
321
worker_processes <%= ENV['NGINX_WORKERS'] || 4 %>;
@@ -124,6 +142,7 @@ http {
124142
add_header X-Content-Type-Options "no-sniff";
125143
add_header X-Frame-Options "SAMEORIGIN";
126144
add_header X-XSS-Protection "1; mode=block";
145+
add_header Content-Security-Policy "default-src 'self'; connect-src 'self' https://docs.rs https://<%= s3_host(ENV) %>; script-src 'self' 'unsafe-eval' https://www.google.com; style-src 'self' https://www.google.com https://ajax.googleapis.com; img-src *; object-src 'none'";
127146

128147
add_header Strict-Transport-Security "max-age=31536000" always;
129148
add_header Vary 'Accept, Accept-Encoding, Cookie';

0 commit comments

Comments
 (0)