This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Nginx target to API Dockerfile (#990)
* Get nginx target building and running Still having a networking issue, but I think it comes down to some gap in my understanding of how the nginx image works and how to forward ports to it properly * Fix CI; publish api-nginx image on release * Simplify CI collectstatic step * Update docker/setup-buildx-action version Co-authored-by: Krystle Salazar <[email protected]> * Update actions * Revert "Update actions" This reverts commit 9d8d419. Co-authored-by: Krystle Salazar <[email protected]>
- Loading branch information
1 parent
ef6cd42
commit 1d841b9
Showing
8 changed files
with
164 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
!manage.py | ||
!Pipfile* | ||
!run.sh | ||
!nginx.conf.template | ||
!static | ||
!nginx-entrypoint.sh |
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 @@ | ||
static/* |
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,85 @@ | ||
error_log /var/log/nginx/error.log; | ||
|
||
log_format json_combined escape=json | ||
'{' | ||
'"time_local":"\$time_local",' | ||
'"remote_addr":"\$remote_addr",' | ||
'"remote_user":"\$remote_user",' | ||
'"request":"\$request",' | ||
'"status": "\$status",' | ||
'"host_header": "\$host",' | ||
'"body_bytes_sent":\$body_bytes_sent,' | ||
'"request_time":"\$request_time",' | ||
'"http_referrer":"\$http_referer",' | ||
'"http_user_agent":"\$http_user_agent",' | ||
'"upstream_response_time":\$upstream_response_time,' | ||
'"http_x_forwarded_for":"\$http_x_forwarded_for"' | ||
'}'; | ||
|
||
access_log /var/log/nginx/access.log json_combined; | ||
|
||
tcp_nopush on; | ||
tcp_nodelay on; | ||
types_hash_max_size 2048; | ||
|
||
# Compress large responses to save bandwidth and improve latency | ||
gzip on; | ||
gzip_min_length 860; | ||
gzip_vary on; | ||
gzip_proxied expired private auth; | ||
gzip_types application/json text/plain application/javascript; | ||
gzip_disable "MSIE [1-6]\."; | ||
|
||
upstream django { | ||
# DJANGO_UPSTREAM_URL must be substituted using a tool like envsubst | ||
server $DJANGO_UPSTREAM_URL; | ||
} | ||
|
||
server { | ||
listen 8080; | ||
server_name _; | ||
charset utf-8; | ||
client_max_body_size 75M; | ||
error_page 500 /500.json; | ||
|
||
location /static { | ||
alias /app/static; | ||
} | ||
|
||
location /media { | ||
alias /app/media; | ||
} | ||
|
||
location / { | ||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto \$scheme; | ||
proxy_set_header Host \$http_host; | ||
proxy_redirect off; | ||
proxy_pass http://django; | ||
error_page 500 /500.json; | ||
} | ||
|
||
location ~ ^/(v1|admin)/ { | ||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto \$scheme; | ||
proxy_set_header Host \$http_host; | ||
proxy_redirect off; | ||
proxy_pass http://django; | ||
error_page 500 /500.json; | ||
} | ||
|
||
location /500.json { | ||
default_type application/json; | ||
return 500 '{"detail": "An internal server error occurred."}'; | ||
} | ||
|
||
location /terms_of_service.html { | ||
root /var/api/api; | ||
index terms_of_service.html; | ||
} | ||
|
||
location /version { | ||
default_type "application/json"; | ||
alias /var/api/version.json; | ||
} | ||
} |
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