forked from screwdriver-cd/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx.conf
84 lines (68 loc) · 2.85 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
load_module /usr/lib/nginx/modules/ndk_http_module.so;
load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
# Used by lua below
env ECOSYSTEM_API;
env ECOSYSTEM_STORE;
env AVATAR_HOSTNAME;
env SDDOC_URL;
env SLACK_URL;
env ROOT_URL;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
# Generated by running `ember csp-headers --environment production`
set_by_lua_block $csp_header {
return "style-src 'self' 'unsafe-inline'; " ..
"connect-src 'self' " .. os.getenv("ECOSYSTEM_API") .. " " .. os.getenv("ECOSYSTEM_STORE") .. "; " ..
"frame-src 'self' " .. os.getenv("ECOSYSTEM_API") .. " " .. os.getenv("ECOSYSTEM_STORE") .. "; " ..
"default-src 'none'; " ..
"script-src 'self'; " ..
"font-src 'self'; " ..
"img-src 'self' https: data: " .. os.getenv("AVATAR_HOSTNAME") .. "; " ..
"media-src 'self';" ..
"worker-src blob:;"
}
add_header x-content-type-options 'nosniff';
add_header x-frame-options 'SAMEORIGIN';
add_header x-xss-protection '1; mode=block';
add_header Content-Security-Policy $csp_header;
set_by_lua_block $rootURL {
return os.getenv("ROOT_URL") or "";
}
location / {
sub_filter_types text/html text/css;
sub_filter "/assets" "$rootURL/assets";
sub_filter_once off;
index index.html;
try_files $uri $uri/ /index.html?/$request_uri;
}
# Dynamic configuration for the ember app
location /assets/supplementary_config.js {
content_by_lua_block {
ngx.say("window.SUPPLEMENTARY_CONFIG = { ROOT_URL: '", os.getenv("ROOT_URL") or "", "', SDAPI_HOSTNAME: '", os.getenv("ECOSYSTEM_API"), "', SDSTORE_HOSTNAME: '", os.getenv("ECOSYSTEM_STORE"), "', SDDOC_URL: '", os.getenv("SDDOC_URL") or "", "', SLACK_URL: '", os.getenv("SLACK_URL") or "", "' };")
}
}
set_by_lua $ecosystem_api 'return os.getenv("ECOSYSTEM_API")';
rewrite ^/pipelines/([^/]*)/badge$ $ecosystem_api/v4/pipelines/$1/badge redirect;
rewrite ^/pipelines/([^/]*)/([^/]*)/badge$ $ecosystem_api/v4/pipelines/$1/$2/badge redirect;
}
}