Files
connexion/examples/openapi3/reverseproxy
Robbe Sneyders 41cc0cb73e Merge pull request #1303 from cuongqn/bugfix/reverseproxy-example
Fix reverseproxy example for OpenAPI 3
2021-07-05 19:30:24 +02:00
..
2019-12-11 17:58:15 -08:00
2019-12-11 17:58:15 -08:00

=====================
Reverse Proxy Example
=====================

This example demonstrates how to run a connexion application behind a path-altering reverse proxy.

You can either set the path in your app, or set the ``X-Forwarded-Path`` header.

Running:

.. code-block:: bash

    $ sudo pip3 install --upgrade connexion[swagger-ui]  # install Connexion from PyPI
    $ ./app.py

Now open your browser and go to http://localhost:8080/reverse_proxied/ui/ to see the Swagger UI.


You can also use the ``X-Forwarded-Path`` header to modify the reverse proxy path.
For example:

.. code-block:: bash

    curl -H "X-Forwarded-Path: /banana/" http://localhost:8080/openapi.json

    {
       "servers" : [
          {
             "url" : "banana/"
          }
       ],
       "paths" : {
          "/hello" : {
             "get" : {
                "responses" : {
                   "200" : {
                      "description" : "hello",
                      "content" : {
                         "text/plain" : {
                            "schema" : {
                               "type" : "string"
                            }
                         }
                      }
                   }
                },
                "operationId" : "app.hello",
                "summary" : "say hi"
             }
          }
       },
       "openapi" : "3.0.0",
       "info" : {
          "version" : "1.0",
          "title" : "Path-Altering Reverse Proxy Example"
       }
    }