-
Notifications
You must be signed in to change notification settings - Fork 5
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
Showing
7 changed files
with
149 additions
and
75 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
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,5 @@ | ||
# The authenticator listens on port 8000, as set | ||
# in authenticator.py. | ||
upstream authenticator { | ||
server 127.0.0.1:8000; | ||
} |
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,54 @@ | ||
# The application listens on port 9000 as implemented | ||
# in service1.py. | ||
upstream service1 { | ||
server 127.0.0.1:9000; | ||
} | ||
|
||
# listen on port 8081 for requests that require | ||
# authentication. Change the port number as appropriate. | ||
server { | ||
listen 8081; | ||
|
||
# Protected application | ||
location / { | ||
# Requests must be authenticated | ||
auth_request /auth-proxy; | ||
|
||
# Relay the REMOTE_USER and X-WEBAUTH-USER headers | ||
# From the response of the authentication request | ||
# To the service | ||
auth_request_set $remoteUser $upstream_http_REMOTE_USER; | ||
proxy_set_header REMOTE_USER $remoteUser; | ||
|
||
auth_request_set $xWebauthUser $upstream_http_X_WEBAUTH_USER; | ||
proxy_set_header X-WEBAUTH-USER $xWebauthUser; | ||
|
||
# redirect 401 and 403 to login form | ||
error_page 401 403 /login; | ||
|
||
proxy_pass http://service1/; | ||
} | ||
|
||
location /login { | ||
proxy_pass http://authenticator/login; | ||
proxy_set_header Host $host:$server_port; | ||
proxy_set_header X-Original-URI $request_uri; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
} | ||
|
||
location /auth-proxy { | ||
internal; | ||
|
||
proxy_pass http://authenticator/; | ||
|
||
proxy_pass_request_body off; | ||
proxy_set_header Content-Length ""; | ||
|
||
proxy_set_header X-Real-IP $remote_addr; | ||
|
||
# Login service returns a redirect to the original URI | ||
# and sets the cookie for the authenticator | ||
proxy_set_header X-Original-URI $request_uri; | ||
proxy_set_header Host $host:$server_port; | ||
} | ||
} |
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,54 @@ | ||
# The application listens on port 7000 as implemented | ||
# in service2.py. | ||
upstream service2 { | ||
server 127.0.0.1:7000; | ||
} | ||
|
||
# listen on port 8082 for requests that require | ||
# authentication. Change the port number as appropriate. | ||
server { | ||
listen 8082; | ||
|
||
# Protected application | ||
location / { | ||
# Requests must be authenticated | ||
auth_request /auth-proxy; | ||
|
||
# Relay the REMOTE_USER and X-WEBAUTH-USER headers | ||
# From the response of the authentication request | ||
# To the service | ||
auth_request_set $remoteUser $upstream_http_REMOTE_USER; | ||
proxy_set_header REMOTE_USER $remoteUser; | ||
|
||
auth_request_set $xWebauthUser $upstream_http_X_WEBAUTH_USER; | ||
proxy_set_header X-WEBAUTH-USER $xWebauthUser; | ||
|
||
# redirect 401 and 403 to login form | ||
error_page 401 403 /login; | ||
|
||
proxy_pass http://service2/; | ||
} | ||
|
||
location /login { | ||
proxy_pass http://authenticator/login; | ||
proxy_set_header Host $host:$server_port; | ||
proxy_set_header X-Original-URI $request_uri; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
} | ||
|
||
location /auth-proxy { | ||
internal; | ||
|
||
proxy_pass http://authenticator/; | ||
|
||
proxy_pass_request_body off; | ||
proxy_set_header Content-Length ""; | ||
|
||
proxy_set_header X-Real-IP $remote_addr; | ||
|
||
# Login service returns a redirect to the original URI | ||
# and sets the cookie for the authenticator | ||
proxy_set_header X-Original-URI $request_uri; | ||
proxy_set_header Host $host:$server_port; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,15 @@ | ||
from flask import Flask, request | ||
|
||
|
||
app = Flask(__name__) | ||
|
||
PORT = 7000 | ||
|
||
@app.route('/', methods=["GET"]) | ||
def home(): | ||
remote_user = request.headers.get('REMOTE_USER') | ||
return "Hello {}, this is service2.".format(remote_user) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(port=PORT, debug=True) |