Skip to content

Commit ece67ec

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 ece67ec

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

config/nginx.conf.erb

+20-1
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+
if region and !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 %>;
@@ -121,9 +139,10 @@ http {
121139
expires max;
122140
}
123141

124-
add_header X-Content-Type-Options "no-sniff";
142+
add_header X-Content-Type-Options "nosniff";
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)