{"componentChunkName":"component---src-templates-default-template-tsx","path":"/documentation/best_practices/local_reverse_proxy/","result":{"data":{"asciidoc":{"id":"206dcc62-d6c7-58eb-8b4c-ee283595d0e0","html":"<div id=\"toc\" class=\"toc\">\n<div id=\"toctitle\">Table of Contents</div>\n<ul class=\"sectlevel1\">\n<li><a href=\"#_enabling_local_app_development_for_hiro_desktop\">Enabling local app development for HIRO Desktop</a></li>\n<li><a href=\"#_installing_a_local_reverse_proxy\">Installing a local reverse proxy</a></li>\n<li><a href=\"#_alternative_deactivate_cors_check_in_browser\">Alternative: deactivate CORS check in browser</a></li>\n</ul>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_enabling_local_app_development_for_hiro_desktop\">Enabling local app development for HIRO Desktop</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>The HIRO API adheres to common web security standards. For browser-based applications, the HTTPS calls and response contain various security-related header attributes according to web security best practices.</p>\n</div>\n<div class=\"paragraph\">\n<p>A HIRO Desktop application is typically hosted on the HIRO server, served from the same URL (<a href=\"https://core.engine.datagroup.de\" class=\"bare\">https://core.engine.datagroup.de</a>) as the HIRO API. During local application development, the application might be launched and tested locally on the developer’s PC. In such a case, the web security header attributes would indicate to the web browser that the requests are coming from a wrong origin and would block the application. These checks need to be bypassed for local application development.</p>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_installing_a_local_reverse_proxy\">Installing a local reverse proxy</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>It is recommended to use a local reverse proxy to modify the header attributes, so that the application runs in the browser correctly during development. In general, any reverse proxy can be used, given that it supports modification of HTTPS header attributes. As an example, we show below how this can be done with nginx. Feel free to use another reverse proxy instead.</p>\n</div>\n<div class=\"paragraph\">\n<p>Installation of nginx as reverse proxy:</p>\n</div>\n<div class=\"ulist\">\n<ul>\n<li>\n<p>Download the current (either mainline or stable) nginx version for your operating system from <a href=\"http://nginx.org/en/download.html\" class=\"bare\">http://nginx.org/en/download.html</a></p>\n</li>\n<li>\n<p>Unzip the nginx archive (zip or tar.gz) on your local PC</p>\n</li>\n<li>\n<p>Modify the nginx.conf file in the “conf” sub folder as stated below</p>\n</li>\n<li>\n<p>Run nginx locally (e.g. run “start nginx.exe” on Windows)</p>\n</li>\n<li>\n<p>Now you can the configured local URL (e.g. “http://localhost:5080/” as graph URL in your HIRO Desktop app</p>\n</li>\n</ul>\n</div>\n<div class=\"paragraph\">\n<p>In the example below, the URL <a href=\"http://localhost:5080\" class=\"bare\">http://localhost:5080</a> is forwarded to <a href=\"https://core.engine.datagroup.de\" class=\"bare\">https://core.engine.datagroup.de</a>. The 'Access-Control-Allow-Origin' header attribute is set to '*' to let the browser accept the API responses. Please note that the “/_g” location needs a slightly different configuration to support websocket connections.</p>\n</div>\n<div class=\"listingblock\">\n<div class=\"title\">nginx reverse proxy configuration</div>\n<div class=\"content\">\n<pre class=\"highlight\"><code class=\"language-nginx\" data-lang=\"nginx\">http {\n    include       mime.types;\n    default_type  application/octet-stream;\n    sendfile        on;\n\n    server {\n        listen       5080;\n        server_name  localhost;\n\n\t\tlocation / {\n\t\t\tproxy_pass https://core.engine.datagroup.de ;\n\t\t\tadd_header 'Access-Control-Allow-Origin' '*' always;\n\t\t\tproxy_hide_header 'Access-Control-Allow-Origin';\n\t\t}\n\n\t\tlocation /_g {\n\t\t\tproxy_pass https://core.engine.datagroup.de/_g ;\n\t\t\tproxy_hide_header 'Access-Control-Allow-Origin';\n\t\t\tproxy_http_version 1.1;\n\t\t\tproxy_set_header Upgrade $http_upgrade;\n\t\t\tproxy_set_header Connection \"Upgrade\";\n\t\t}\n    }\n}</code></pre>\n</div>\n</div>\n</div>\n</div>\n<div class=\"sect1\">\n<h2 id=\"_alternative_deactivate_cors_check_in_browser\">Alternative: deactivate CORS check in browser</h2>\n<div class=\"sectionbody\">\n<div class=\"paragraph\">\n<p>It is recommended to use the reverse proxy method described above. If for some reason it is not possible or not desired to run a local reverse proxy, there is a workaround available to temporarily deactivate the CORS check in your web browser via a plugin.\nFor security reasons, we recommend using a second browser for this method, so that only the application under development is run without active CORS check. For example, if your main browser is Chrome, you may use Fire-fox to locally test the application, or vice versa.\nYou may use, for example, the “CORS Everywhere” plugin for Firefox. As you can see in the screenshot in Figure 1, you may (and should) limit the plugin to a whitelist of URLs. Also the plugin is by default switched off after opening the web browser; it needs to be activated by pressing a button. At the next browser restart, the plugin is inactive again.</p>\n</div>\n<div class=\"imageblock\">\n<div class=\"content\">\n<img src=\"/7.0/images/documentation/cors_plugin_settings.png\" alt=\"Screenshot of &quot;CORS Everywhere&quot; Firefox plugin settings\">\n</div>\n<div class=\"title\">Figure 1. Screenshot of \"CORS Everywhere\" Firefox plugin settings</div>\n</div>\n<div class=\"imageblock\">\n<div class=\"content\">\n<img src=\"/7.0/images/documentation/cors_plugin_activation.png\" alt=\"CORS browser plugin is disabled by default when the browser is opened\">\n</div>\n<div class=\"title\">Figure 2. CORS browaer plugin is disabled by default when the browser is opened</div>\n</div>\n</div>\n</div>","document":{"main":"Reverse Proxy for HIRO Desktop Development","title":"Reverse Proxy for HIRO Desktop Development","subtitle":""},"fields":{"toc":true,"location":["documentation","best_practices","local_reverse_proxy"]}},"sidebarYaml":{"id":"6d066bdd-c982-5a69-b909-a31e6fc044e0","showIndex":null}},"pageContext":{"id":"206dcc62-d6c7-58eb-8b4c-ee283595d0e0","parent":"documentation"}},"staticQueryHashes":["1010459453","1010459453","2356112386","2356112386","2603905930","2603905930","3026652197","3026652197","3167850324","3167850324","63159454","63159454"]}