diff --git a/setup/splashpage.sh b/setup/splashpage.sh index a16155b65..44d10802f 100755 --- a/setup/splashpage.sh +++ b/setup/splashpage.sh @@ -29,11 +29,11 @@ if [[ "${arg_retire_reason}" != "" || "${existing_infra}" != "${current_infra}" echo "Showing progress bar on all subdomains in retired mode or infra update. retire: ${arg_retire_reason} existing: ${existing_infra} current: ${current_infra}" rm -f ${DATA_DIR}/nginx/applications/* ${BOX_SRC_DIR}/node_modules/.bin/ejs-cli -f "${script_dir}/start/nginx/appconfig.ejs" \ - -O "{ \"vhost\": \"~^(.+)\$\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"splash\", \"sourceDir\": \"${SETUP_WEBSITE_DIR}\", \"certFilePath\": \"cert/host.cert\", \"keyFilePath\": \"cert/host.key\" }" > "${DATA_DIR}/nginx/applications/admin.conf" + -O "{ \"vhost\": \"~^(.+)\$\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"splash\", \"sourceDir\": \"${SETUP_WEBSITE_DIR}\", \"certFilePath\": \"cert/host.cert\", \"keyFilePath\": \"cert/host.key\", \"xFrameOptions\": \"SAMEORIGIN\" }" > "${DATA_DIR}/nginx/applications/admin.conf" else echo "Show progress bar only on admin domain for normal update" ${BOX_SRC_DIR}/node_modules/.bin/ejs-cli -f "${script_dir}/start/nginx/appconfig.ejs" \ - -O "{ \"vhost\": \"${admin_fqdn}\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"splash\", \"sourceDir\": \"${SETUP_WEBSITE_DIR}\", \"certFilePath\": \"cert/host.cert\", \"keyFilePath\": \"cert/host.key\" }" > "${DATA_DIR}/nginx/applications/admin.conf" + -O "{ \"vhost\": \"${admin_fqdn}\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"splash\", \"sourceDir\": \"${SETUP_WEBSITE_DIR}\", \"certFilePath\": \"cert/host.cert\", \"keyFilePath\": \"cert/host.key\", \"xFrameOptions\": \"SAMEORIGIN\" }" > "${DATA_DIR}/nginx/applications/admin.conf" fi if [[ "${arg_retire_reason}" == "migrate" ]]; then diff --git a/setup/start.sh b/setup/start.sh index 2f00d714a..a0ace6d43 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -110,7 +110,7 @@ if [[ -f "${DATA_DIR}/box/certs/${admin_fqdn}.cert" && -f "${DATA_DIR}/box/certs admin_key_file="${DATA_DIR}/box/certs/${admin_fqdn}.key" fi ${BOX_SRC_DIR}/node_modules/.bin/ejs-cli -f "${script_dir}/start/nginx/appconfig.ejs" \ - -O "{ \"vhost\": \"${admin_fqdn}\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"admin\", \"sourceDir\": \"${BOX_SRC_DIR}\", \"certFilePath\": \"${admin_cert_file}\", \"keyFilePath\": \"${admin_key_file}\" }" > "${DATA_DIR}/nginx/applications/admin.conf" + -O "{ \"vhost\": \"${admin_fqdn}\", \"adminOrigin\": \"${admin_origin}\", \"endpoint\": \"admin\", \"sourceDir\": \"${BOX_SRC_DIR}\", \"certFilePath\": \"${admin_cert_file}\", \"keyFilePath\": \"${admin_key_file}\", \"xFrameOptions\": \"SAMEORIGIN\" }" > "${DATA_DIR}/nginx/applications/admin.conf" mkdir -p "${DATA_DIR}/nginx/cert" if [[ -f "${DATA_DIR}/box/certs/host.cert" && -f "${DATA_DIR}/box/certs/host.key" ]]; then diff --git a/setup/start/nginx/appconfig.ejs b/setup/start/nginx/appconfig.ejs index f3e39bf13..8aeb11732 100644 --- a/setup/start/nginx/appconfig.ejs +++ b/setup/start/nginx/appconfig.ejs @@ -25,7 +25,7 @@ server { add_header Strict-Transport-Security "max-age=15768000; includeSubDomains"; # https://developer.mozilla.org/en-US/docs/Web/HTTP/X-Frame-Options - add_header X-Frame-Options SAMEORIGIN; + add_header X-Frame-Options <%= xFrameOptions %>; proxy_http_version 1.1; proxy_intercept_errors on; diff --git a/src/nginx.js b/src/nginx.js index b72de73f7..1020a22e4 100644 --- a/src/nginx.js +++ b/src/nginx.js @@ -45,7 +45,8 @@ function configureAdmin(certFilePath, keyFilePath, callback) { vhost: config.adminFqdn(), endpoint: 'admin', certFilePath: certFilePath, - keyFilePath: keyFilePath + keyFilePath: keyFilePath, + xFrameOptions: 'SAMEORIGIN' }; var nginxConf = ejs.render(NGINX_APPCONFIG_EJS, data); var nginxConfigFilename = path.join(paths.NGINX_APPCONFIG_DIR, 'admin.conf'); @@ -73,7 +74,8 @@ function configureApp(app, certFilePath, keyFilePath, callback) { port: app.httpPort, endpoint: endpoint, certFilePath: certFilePath, - keyFilePath: keyFilePath + keyFilePath: keyFilePath, + xFrameOptions: 'SAMEORIGIN' }; var nginxConf = ejs.render(NGINX_APPCONFIG_EJS, data);