-
-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Julien Sagnard
committed
Jan 8, 2019
1 parent
a0ac0fd
commit 9433d75
Showing
12 changed files
with
219 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,6 @@ htmlcov/ | |
*.swp | ||
.tox/ | ||
.idea/ | ||
venv | ||
.vscode | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
===================== | ||
External Reverse Proxy Example | ||
===================== | ||
|
||
This example demonstrates how to run a connexion application behind an external reverse proxy with rewrite rule. | ||
|
||
Setup NGINX reverse proxy: | ||
|
||
.. code-block:: NGINX | ||
server { | ||
listen 9000; | ||
listen [::]:9000; | ||
server_name example.com; | ||
location /reverse_proxied/ { | ||
# Define the location of the proxy server to send the request to | ||
proxy_pass http://localhost:8080/; | ||
# Add prefix header | ||
proxy_set_header X-Forwarded-Prefix $scheme://$host:$server_port/reverse_proxied; | ||
} | ||
} | ||
And start application: | ||
|
||
.. code-block:: bash | ||
$ sudo pip3 install --upgrade connexion[swagger-ui] # install Connexion from PyPI | ||
$ ./app.py | ||
Swagger UI can be accessed with direct connexion: | ||
|
||
http://localhost:8080/v1/ui | ||
|
||
And through NGINX proxy with rewrite rule: | ||
|
||
http://localhost:9000/reverse_proxied/v1/ui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import connexion | ||
|
||
|
||
def hello(): | ||
return "hello" | ||
|
||
|
||
if __name__ == '__main__': | ||
app = connexion.FlaskApp(__name__, options={'proxy_uri_prefix_header': 'X-Forwarded-Prefix'}) | ||
app.add_api('openapi/openapi.yaml') | ||
app.run(port=8080) | ||
|
18 changes: 18 additions & 0 deletions
18
examples/openapi3/external_reverse_proxy/openapi/openapi.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Path-Altering Reverse Proxy Example | ||
version: '1.0' | ||
servers: | ||
- url: http://localhost:8080/v1 | ||
paths: | ||
/hello: | ||
get: | ||
summary: say hi | ||
operationId: app.hello | ||
responses: | ||
'200': | ||
description: hello | ||
content: | ||
text/plain: | ||
schema: | ||
type: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters