From bc987a566368f3dd7606c765f8ff8b3ccc2ebf51 Mon Sep 17 00:00:00 2001 From: cytopia Date: Wed, 6 Mar 2019 14:10:04 +0100 Subject: [PATCH] \#453 Add Ngrok Documentation --- README.md | 9 +- docs/_includes/links/documentation.rst | 12 ++ .../snippets/additional-container.rst | 2 + .../docker-compose-override-tree-view.rst | 1 + .../showcase-over-the-internet.rst | 133 +++++++++++++ .../custom-container/enable-all-container.rst | 1 + docs/custom-container/enable-ngrok.rst | 186 ++++++++++++++++++ docs/index.rst | 2 + 8 files changed, 344 insertions(+), 2 deletions(-) create mode 100644 docs/corporate-usage/showcase-over-the-internet.rst create mode 100644 docs/custom-container/enable-ngrok.rst diff --git a/README.md b/README.md index 6b304eec..f6a9839f 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ Each of them is also available in multiple different versions in order to reflec | HAProxy | Apache | MariaDB | Memcached | RabbitMQ | Solr | ElasticSearch | Bind | | Varnish | Nginx | MySQL | MongoDB | | | Logstash | Blackfire | | | PHP | PerconaDB | Redis | | | Kibana | MailHog | -| | | PostgreSQL | | | | | | +| | | PostgreSQL | | | | | Ngrok | > **Documentation:** > [Available Container](https://devilbox.readthedocs.io/en/latest/readings/available-container.html) @@ -363,6 +363,7 @@ Additionally to the default stack, there are a variety of other services that ca Blackfire ELK MailHog + Ngrok RabbitMQ Solr HAProxy @@ -374,15 +375,17 @@ Additionally to the default stack, there are a variety of other services that ca 1.8 5.x.y v1.0.0 + 2.x 3.6 5 - 1.X + 1.x 4 ... 6.x.y latest + 3.7 6 @@ -392,6 +395,7 @@ Additionally to the default stack, there are a variety of other services that ca 1.18.0 7.x.y + latest 7 @@ -402,6 +406,7 @@ Additionally to the default stack, there are a variety of other services that ca + latest latest diff --git a/docs/_includes/links/documentation.rst b/docs/_includes/links/documentation.rst index a4b6f951..9e3e31a8 100644 --- a/docs/_includes/links/documentation.rst +++ b/docs/_includes/links/documentation.rst @@ -40,6 +40,18 @@ Dockerhub: MailHog +.. |ext_lnk_ngrok_github| raw:: html + + + Github: ngrok + + +.. |ext_lnk_ngrok_dockerhub| raw:: html + + + Dockerhub: ngrok + + .. |ext_lnk_blackfire_github| raw:: html diff --git a/docs/_includes/snippets/additional-container.rst b/docs/_includes/snippets/additional-container.rst index 06142b72..b3b8f8b1 100644 --- a/docs/_includes/snippets/additional-container.rst +++ b/docs/_includes/snippets/additional-container.rst @@ -5,6 +5,8 @@ +-------------------------------------+-----------+-----------+----------------+ | MailHog | mailhog | mailhog | 172.16.238.201 | +-------------------------------------+-----------+-----------+----------------+ +| Ngrok | ngrok | ngrok | 172.16.238.202 | ++-------------------------------------+-----------+-----------+----------------+ | RabbitMQ | rabbit | rabbit | 172.16.238.210 | +-------------------------------------+-----------+-----------+----------------+ | Solr | solr | solr | 172.16.238.220 | diff --git a/docs/_includes/snippets/docker-compose-override-tree-view.rst b/docs/_includes/snippets/docker-compose-override-tree-view.rst index 00b0d615..688d740b 100644 --- a/docs/_includes/snippets/docker-compose-override-tree-view.rst +++ b/docs/_includes/snippets/docker-compose-override-tree-view.rst @@ -12,6 +12,7 @@ However, each example also exists in its standalone file as shown below: ├── docker-compose.override.yml-blackfire ├── docker-compose.override.yml-elk ├── docker-compose.override.yml-mailhog + ├── docker-compose.override.yml-ngrok ├── docker-compose.override.yml-rabbitmq ├── docker-compose.override.yml-solr ├── docker-compose.override.yml-varnish diff --git a/docs/corporate-usage/showcase-over-the-internet.rst b/docs/corporate-usage/showcase-over-the-internet.rst new file mode 100644 index 00000000..cad6d128 --- /dev/null +++ b/docs/corporate-usage/showcase-over-the-internet.rst @@ -0,0 +1,133 @@ +.. include:: /_includes/all.rst + +.. _showcase_over_the_internet: + +************************** +Showcase over the internet +************************** + +**Table of Contents** + +.. contents:: :local: + + +Why +=== + +Sometimes it is just convinient to make your local project available over the internet to quickly +showcase your current work to a customer. Instead of having to deploy it somewhere and even be able +to live code during the showcase the Devilbox provides an easy way to accomplish exactly this via +Ngrok. + + +How +=== + +First you want to add Ngrok to the Devilbox stack via its pre-defined Docker Compose override file. + +.. seealso:: * :ref:`custom_container_enable_ngrok` + +Once you have followed the above documentation everything works with default settings. To actually +customize and choose the virtual host to expose you will need to alter the ``NGROK_HTTP_TUNNELS`` +.env variable. + +How this can be done exactly will be shown in a couple of examples below. + +Examples +-------- + +Recall the following formats for the variable: + +* ``::`` +* ``::,::`` + +.. note:: Even more than two tunnels are supported, but this will again depend on your Ngrok license. + +Where each individual part consists of: + +* ```` is the virtual hostname that you want to serve via Ngrok +* ```` is the hostname or IP address of the web server +* ```` is the port on which the web server is reachable via HTTP + +Expose ``my-project.loc`` via web server +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* ````: my-project.loc +* ````: httpd +* ````: httpd80 + +So the resulting ``.env`` value will be: + +.. code-block:: bash + + NGROK_HTTP_TUNNELS=my-project.loc:httpd:80 + +Expose ``my-project.loc`` via Varnish +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* ````: my-project.loc +* ````: varnish +* ````: 6081 + +So the resulting ``.env`` value will be: + +.. code-block:: bash + + NGROK_HTTP_TUNNELS=my-project.loc:varnish:6081 + +Expose ``my-project.loc`` via HAProxy +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +* ````: my-project.loc +* ````: haproxy +* ````: 80 + +So the resulting ``.env`` value will be: + +.. code-block:: bash + + NGROK_HTTP_TUNNELS=my-project.loc:haproxy:80 + + +Expose ``my-project.loc`` and ``website1.loc`` via web server +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. note:: Exposing more than one vhost will require a pro enough license from Ngrok. + +* ````: my-project.loc +* ````: httpd +* ````: 80 + +and + +* ````: website1.loc +* ````: httpd +* ````: 80 + + +So the resulting ``.env`` value will be: + +.. code-block:: bash + + NGROK_HTTP_TUNNELS=my-project.loc:httpd:80,website1.loc:httpd:80 + +Expose ``my-project.loc`` via web server and varnish +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. note:: Exposing more than one vhost will require a pro enough license from Ngrok. + +* ````: my-project.loc +* ````: httpd +* ````: 80 + +and + + +* ````: my-project.loc +* ````: varnish +* ````: 6081 + +So the resulting ``.env`` value will be: + +.. code-block:: bash + + NGROK_HTTP_TUNNELS=my-project.loc:httpd:80,my-project.loc:varnish:6081 diff --git a/docs/custom-container/enable-all-container.rst b/docs/custom-container/enable-all-container.rst index 516b2906..e1e5c1f4 100644 --- a/docs/custom-container/enable-all-container.rst +++ b/docs/custom-container/enable-all-container.rst @@ -58,6 +58,7 @@ In order to fully customize each container, refer to their own documentation sec * :ref:`custom_container_enable_blackfire` * :ref:`custom_container_enable_elk_stack` * :ref:`custom_container_enable_mailhog` + * :ref:`custom_container_enable_ngrok` * :ref:`custom_container_enable_rabbitmq` * :ref:`custom_container_enable_solr` * :ref:`custom_container_enable_varnish` diff --git a/docs/custom-container/enable-ngrok.rst b/docs/custom-container/enable-ngrok.rst new file mode 100644 index 00000000..22947248 --- /dev/null +++ b/docs/custom-container/enable-ngrok.rst @@ -0,0 +1,186 @@ +.. include:: /_includes/all.rst + +.. _custom_container_enable_ngrok: + +************************** +Enable and configure Ngrok +************************** + +This section will guide you through getting Ngrok integrated into the Devilbox. + +.. seealso:: + * |ext_lnk_ngrok_github| + * |ext_lnk_ngrok_dockerhub| + * :ref:`custom_container_enable_all_additional_container` + * :ref:`docker_compose_override_yml_how_does_it_work` + + +**Table of Contents** + +.. contents:: :local: + + +Overview +======== + +Available overwrites +-------------------- + +.. include:: /_includes/snippets/docker-compose-override-tree-view.rst + + +Ngrok settings +-------------- + +In case of Ngrok, the file is ``compose/docker-compose.override.yml-ngrok``. This file +must be copied into the root of the Devilbox git directory. + ++-----------------------+-----------------------------------------------------------------------------------------------------+ +| What | How and where | ++=======================+=====================================================================================================+ +| Example compose file | ``compose/docker-compose.override.yml-all`` or |br| ``compose/docker-compose.override.yml-ngrok`` | ++-----------------------+-----------------------------------------------------------------------------------------------------+ +| Container IP address | ``172.16.238.202`` | ++-----------------------+-----------------------------------------------------------------------------------------------------+ +| Container host name | ``ngrok`` | ++-----------------------+-----------------------------------------------------------------------------------------------------+ +| Container name | ``ngrok`` | ++-----------------------+-----------------------------------------------------------------------------------------------------+ +| Mount points | none | ++-----------------------+-----------------------------------------------------------------------------------------------------+ +| Exposed port | ``4040`` (can be changed via ``.env``) | ++-----------------------+-----------------------------------------------------------------------------------------------------+ +| Available at | ``http://localhost:4040`` | ++-----------------------+-----------------------------------------------------------------------------------------------------+ +| Further configuration | ``NGROK_HTTP_TUNNELS`` and ``NGROK_AUTHTOKEN`` | ++-----------------------+-----------------------------------------------------------------------------------------------------+ + +Ngrok env variables +------------------- + +Additionally the following ``.env`` variables can be created for easy configuration: + ++------------------------------+--------------------+----------------------------------------------------------------------+ +| Variable | Default value | Description | ++==============================+====================+======================================================================+ +| ``HOST_PORT_NGROK`` | ``4040`` | Controls the host port on which Ngrok admin UI will be available at. | ++------------------------------+--------------------+----------------------------------------------------------------------+ +| ``NGROK_HTTP_TUNNELS`` | ``httpd:httpd:80`` | Defines one or more Ngrok tunnels (depending on your license) | ++------------------------------+--------------------+----------------------------------------------------------------------+ +| ``NGROK_AUTHTOKEN`` | empty | Free or paid license token for Ngrok (can also be empty) | ++------------------------------+--------------------+----------------------------------------------------------------------+ + +NGROK_HTTP_TUNNELS +^^^^^^^^^^^^^^^^^^ + +Ngrok tunnel definitions can be in the form of: + +* ``::`` +* ``::,::`` + +.. note:: + If you don't use a license you can only specify a single tunnel. If your license is pro enough, + you can have multiple comma separated tunnels. + +* ```` is the virtual hostname that you want to serve via Ngrok +* ```` is the hostname or IP address of the web server +* ```` is the port on which the web server is reachable via HTTP + +.. code-block:: bash + + # Make vhost "project1.loc" which runs on localhost:8080 available + HTTP_TUNNELS=project1.loc:localhost:8080 + + # Make two vhosts available which run on host apache:80 + HTTP_TUNNELS=project1.loc:apache:80,project2.loc:apache:80 + + # Make two vhosts from two different web server addresses available + HTTP_TUNNELS=project1.loc:localhost:8080,project2.loc:apache:80 + + +Instructions +============ + +1. Copy docker-compose.override.yml +----------------------------------- + +Copy the Ngrok Docker Compose overwrite file into the root of the Devilbox git directory. +(It must be at the same level as the default ``docker-compose.yml`` file). + +.. code-block:: bash + + host> cp compose/docker-compose.override.yml-ngrok docker-compose.override.yml + +.. seealso:: + * :ref:`docker_compose_override_yml` + * :ref:`add_your_own_docker_image` + * :ref:`overwrite_existing_docker_image` + + +2. Adjust ``.env`` settings (optional) +-------------------------------------- + +By Default Ngrok will forward the ``httpd`` domain, which is represents the default virtual host +(the Devilbox intranet) to your web server (also named ``httpd``) and makes the admin UI available +on port ``4040`` on your local machine. + +You can of course change the domain as well as where to forward it to (e.g.: to Varnish or HAProxy +instead). + +Additionally you can also specify a license token in order to allow for more tunnels via +``NGROK_AUTHTOKEN``. + +.. code-block:: bash + :caption: .env + + HOST_PORT_NGROK=4040 + # Share project1.loca over the internet + NGROK_HTTP_TUNNELS=project1.loc:httpd:80 + # No license token specified + NGROK_AUTHTOKEN= + +.. seealso:: :ref:`env_file` + + +3. Start the Devilbox +--------------------- + +The final step is to start the Devilbox with Ngrok. + +Let's assume you want to start ``php``, ``httpd``, ``bind`` and ``ngrok``. + +.. code-block:: bash + + host> docker-compose up -d php httpd bind ngrok + +.. seealso:: :ref:`start_the_devilbox` + + +4. Start using it +----------------- + +* Once the Devilbox is running, visit http://localhost:4040 in your browser. +* Get URL for public available project + + +TL;DR +===== + +For the lazy readers, here are all commands required to get you started. +Simply copy and paste the following block into your terminal from the root of your Devilbox git +directory: + +.. code-block:: bash + + # Copy compose-override.yml into place + cp compose/docker-compose.override.yml-ngrok docker-compose.override.yml + + # Create .env variable + echo "HOST_PORT_NGROK=4040" >> .env + echo "# Share project1.loca over the internet" >> .env + echo "NGROK_HTTP_TUNNELS=project1.loc:httpd:80" >> .env + echo "# No license token specified" >> .env + echo "NGROK_AUTHTOKEN=" >> .env + + # Start container + docker-compose up -d php httpd bind ngrok diff --git a/docs/index.rst b/docs/index.rst index 135e9af5..fcc5e6a1 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -121,6 +121,7 @@ host is ready to be served with your custom domain. custom-container/enable-blackfire custom-container/enable-elk-stack custom-container/enable-mailhog + custom-container/enable-ngrok custom-container/enable-rabbitmq custom-container/enable-solr custom-container/enable-varnish @@ -132,6 +133,7 @@ host is ready to be served with your custom domain. corporate-usage/shared-devilbox-server-in-lan corporate-usage/use-external-databases + corporate-usage/showcase-over-the-internet .. corporate-usage/deploy-devilbox-via-ansible corporate-usage/access-colleagues-devilbox