-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check in a simple docker-compose to run the app behind an nginx proxy
So that we can test the reverse proxy configuration fixes in dev This fixes #24 (comment) The `docker-compose` (except for `nginx`) should be kept consistent with the production `docker-compose-prod.yml` with the exception of `DASH_DEBUG_MODE`, which is set to true so that we can debug errors in the setup more easily Testing done: - Built and ran the docker-compose - Accessing http://localhost:8060/admin gives the same error as #24 (comment) ``` Uncaught ReferenceError: DashRenderer is not defined <anonymous> http://localhost:8060/admin/:58 ```
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 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,51 @@ | ||
# docker-compose-prod-ngnix.yml | ||
# used for testing with the ngnix reverse proxy | ||
version: "3" | ||
services: | ||
dashboard: | ||
build: | ||
context: . | ||
dockerfile: docker/Dockerfile | ||
image: e-mission/opdash:0.0.1 | ||
environment: | ||
DASH_DEBUG_MODE: "True" | ||
DASH_SERVER_PORT: 8050 | ||
DB_HOST: db | ||
WEB_SERVER_HOST: 0.0.0.0 | ||
SERVER_BRANCH: master | ||
CONFIG_PATH: "https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/" | ||
STUDY_NAME: "stage-program" | ||
AUTH_TYPE: "basic" # the other option is cognito | ||
DASH_REQUESTS_PATHNAME_PREFIX: "/" | ||
networks: | ||
- emission | ||
deploy: | ||
restart_policy: | ||
condition: on-failure | ||
depends_on: | ||
- db | ||
- nginxrp | ||
db: | ||
image: mongo:4.4.0 | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: on-failure | ||
networks: | ||
- emission | ||
nginxrp: | ||
image: nginx:1.24.0 | ||
deploy: | ||
replicas: 1 | ||
restart_policy: | ||
condition: on-failure | ||
networks: | ||
- emission | ||
volumes: | ||
- ./docker/ngnix.conf:/etc/nginx/nginx.conf:ro | ||
ports: | ||
- "8060:80" | ||
|
||
|
||
networks: | ||
emission: |
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,46 @@ | ||
events { } | ||
http { | ||
server { | ||
listen 80; | ||
charset utf-8; | ||
server_tokens off; | ||
|
||
# Re-enable once we have figured out how to get the set_headers module to work | ||
# more_set_headers "X-XSS-Protection: 1; mode=block"; | ||
# more_set_headers "Access-Control-Allow-Origin: $host"; | ||
# more_set_headers "X-Frame-Options: SAMEORIGIN"; | ||
# more_set_headers "Referrer-Policy: same-origin"; | ||
# more_set_headers "Allow: GET, POST, HEAD"; | ||
if ($request_method ~ ^(OPTIONS)$ ) { return 403; } | ||
|
||
# proxy_cookie_path off; | ||
# proxy_cookie_path / "/; HTTPOnly; Secure"; | ||
|
||
error_page 404 https://www.nrel.gov/notfound; | ||
|
||
location /static { | ||
alias /www/static; | ||
} | ||
|
||
location / { | ||
rewrite /(.+$) /api/$1 break; | ||
} | ||
|
||
location /admin/ { | ||
proxy_pass http://dashboard:8050/; | ||
proxy_pass_header Content-Type; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_hide_header Access-Control-Allow-Origin; | ||
proxy_http_version 1.1; | ||
proxy_set_header Upgrade $http_upgrade; | ||
proxy_set_header Connection "upgrade"; | ||
proxy_set_header Host $host; | ||
proxy_cookie_path / "/; Secure; HttpOnly; SameSite=strict"; | ||
client_max_body_size 1G; | ||
proxy_read_timeout 300; | ||
proxy_connect_timeout 300; | ||
proxy_send_timeout 300; | ||
} | ||
} | ||
} |