diff --git a/build/cmake/core-web-app.cmake b/build/cmake/core-web-app.cmake index 7f6bcf439..9d826f61e 100644 --- a/build/cmake/core-web-app.cmake +++ b/build/cmake/core-web-app.cmake @@ -13,6 +13,17 @@ add_custom_command( COMMAND touch ${STAMP_DIR}/core-web-app-bundle ) +file(GLOB_RECURSE web_app_public_files + ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/public/*.html +) +add_custom_command( + OUTPUT ${STAMP_DIR}/core-web-app-public + DEPENDS ${web_app_public_files} + COMMAND mkdir -p ${CORE_BUILD_DIR}/tmp/web-app-build/public + COMMAND rsync -a --delete-after ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/public/ ${CORE_BUILD_DIR}/tmp/web-app-build/public/ + COMMAND touch ${STAMP_DIR}/core-web-app-public +) + file(GLOB_RECURSE web_asset_files ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/app/assets/*.css ${CMAKE_SOURCE_DIR}/src/api-umbrella/web-app/app/assets/*.scss diff --git a/build/cmake/core.cmake b/build/cmake/core.cmake index 959f10e14..1814a2a45 100644 --- a/build/cmake/core.cmake +++ b/build/cmake/core.cmake @@ -33,14 +33,16 @@ add_custom_command( add_custom_command( OUTPUT ${STAMP_DIR}/core-build-install-dist - ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-assets + ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-public ${CORE_BUILD_DIR}/releases/0/build/dist/admin-ui DEPENDS ${STAMP_DIR}/core-admin-ui-build + ${STAMP_DIR}/core-web-app-public ${STAMP_DIR}/core-web-app-precompile ${STAMP_DIR}/core-build-release-dir - COMMAND mkdir -p ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-assets - COMMAND rsync -a --delete-after ${CORE_BUILD_DIR}/tmp/web-app-build/web-assets/ ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-assets/web-assets/ + COMMAND mkdir -p ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-public + COMMAND rsync -a --delete-after ${CORE_BUILD_DIR}/tmp/web-app-build/public/ ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-public/ + COMMAND rsync -a --delete-after ${CORE_BUILD_DIR}/tmp/web-app-build/web-assets/ ${CORE_BUILD_DIR}/releases/0/build/dist/web-app-public/web-assets/ COMMAND rsync -a --delete-after ${CORE_BUILD_DIR}/tmp/admin-ui-build/dist/ ${CORE_BUILD_DIR}/releases/0/build/dist/admin-ui/ COMMAND touch ${STAMP_DIR}/core-build-install-dist ) diff --git a/src/api-umbrella/web-app/public/404.html b/src/api-umbrella/web-app/public/404.html new file mode 100644 index 000000000..2b37e838f --- /dev/null +++ b/src/api-umbrella/web-app/public/404.html @@ -0,0 +1,7 @@ + + 404 Not Found + +

404 Not Found

+
API Umbrella
+ + diff --git a/src/api-umbrella/web-app/public/422.html b/src/api-umbrella/web-app/public/422.html new file mode 100644 index 000000000..95cfd74d6 --- /dev/null +++ b/src/api-umbrella/web-app/public/422.html @@ -0,0 +1,7 @@ + + 422 Unprocessable Entity + +

422 Unprocessable Entity

+
API Umbrella
+ + diff --git a/src/api-umbrella/web-app/public/500.html b/src/api-umbrella/web-app/public/500.html new file mode 100644 index 000000000..4912e2387 --- /dev/null +++ b/src/api-umbrella/web-app/public/500.html @@ -0,0 +1,7 @@ + + 500 Internal Server Error + +

500 Internal Server Error

+
API Umbrella
+ + diff --git a/templates/etc/nginx/router.conf.mustache b/templates/etc/nginx/router.conf.mustache index 87fed9ff4..6cc29e435 100644 --- a/templates/etc/nginx/router.conf.mustache +++ b/templates/etc/nginx/router.conf.mustache @@ -362,7 +362,7 @@ http { {{^_development_env?}} location /web-assets/ { more_set_headers "Cache-Control: public, max-age=31536000, immutable"; - alias {{_embedded_root_dir}}/apps/core/current/build/dist/web-app-assets/web-assets/; + alias {{_embedded_root_dir}}/apps/core/current/build/dist/web-app-public/web-assets/; } {{/_development_env?}} diff --git a/templates/etc/perp/web-delayed-job/rc.env.mustache b/templates/etc/perp/web-delayed-job/rc.env.mustache index 302fea6c0..2bfd50fe6 100644 --- a/templates/etc/perp/web-delayed-job/rc.env.mustache +++ b/templates/etc/perp/web-delayed-job/rc.env.mustache @@ -2,7 +2,7 @@ RAILS_ENV={{app_env}} DELAYED_JOB=true API_UMBRELLA_RUNTIME_CONFIG={{_api_umbrella_config_runtime_file}} RAILS_TMP_PATH={{tmp_dir}}/web-app -RAILS_PUBLIC_PATH={{_embedded_root_dir}}/apps/core/current/build/dist/web-app-assets +RAILS_PUBLIC_PATH={{_embedded_root_dir}}/apps/core/current/build/dist/web-app-public # Set the HOME path for Bundler to a writable directory to prevent warnings in # Bundler 1.14+: # https://github.com/bundler/bundler/issues/5372 Note that we diff --git a/templates/etc/perp/web-puma/rc.env.mustache b/templates/etc/perp/web-puma/rc.env.mustache index 49b5f2ed0..bb8435951 100644 --- a/templates/etc/perp/web-puma/rc.env.mustache +++ b/templates/etc/perp/web-puma/rc.env.mustache @@ -1,7 +1,7 @@ RAILS_ENV={{app_env}} API_UMBRELLA_RUNTIME_CONFIG={{_api_umbrella_config_runtime_file}} RAILS_TMP_PATH={{tmp_dir}}/web-app -RAILS_PUBLIC_PATH={{_embedded_root_dir}}/apps/core/current/build/dist/web-app-assets +RAILS_PUBLIC_PATH={{_embedded_root_dir}}/apps/core/current/build/dist/web-app-public # Set the HOME path for Bundler to a writable directory to prevent warnings in # Bundler 1.14+: # https://github.com/bundler/bundler/issues/5372 Note that we diff --git a/test/proxy/test_nginx_rewrites.rb b/test/proxy/test_nginx_rewrites.rb index 89ddb3b22..2a265e870 100644 --- a/test/proxy/test_nginx_rewrites.rb +++ b/test/proxy/test_nginx_rewrites.rb @@ -124,6 +124,7 @@ def test_precedence "^/#{unique_test_id}/api-example/rewrite_me$ https://example.com/ permanent", "^/#{unique_test_id}/website-example/rewrite_me$ https://2.example.com/ permanent", "^/admin/rewrite_me$ https://3.example.com/ permanent", + "^/admin/login/rewrite_me$ https://4.example.com/ permanent", ], }, ], @@ -148,13 +149,21 @@ def test_precedence assert_response_code(404, response) assert_match("Test 404 Not Found", response.body) - # Rewrites match before the admin tool. + # Rewrites match before the admin tool's static content. response = Typhoeus.get("https://127.0.0.1:9081/admin/rewrite_me", http_opts) assert_response_code(301, response) assert_equal("https://3.example.com/", response.headers["location"]) response = Typhoeus.get("https://127.0.0.1:9081/admin/rewrite_me_just_kidding", http_opts) assert_response_code(404, response) assert_match("
openresty
", response.body) + + # Rewrites match before the admin tool's dynamic app. + response = Typhoeus.get("https://127.0.0.1:9081/admin/login/rewrite_me", http_opts) + assert_response_code(301, response) + assert_equal("https://4.example.com/", response.headers["location"]) + response = Typhoeus.get("https://127.0.0.1:9081/admin/login/rewrite_me_just_kidding", http_opts) + assert_response_code(404, response) + assert_match("
API Umbrella
", response.body) end end end