From 67334d5dd0778c53569aeec955040aa4a9830c87 Mon Sep 17 00:00:00 2001 From: Ben Sherriff Date: Sat, 12 Apr 2025 23:47:47 -0400 Subject: [PATCH] Tweaking nginx and env vars --- .env | 9 ++------- api/src/main.rs | 2 +- bruno/environments/Localhost.bru | 3 ++- docker-compose.yml | 1 - nginx/templates/nossl.conf.template | 6 +++--- nginx/templates/ssl.conf.template | 6 +++--- 6 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.env b/.env index 6890579..6fa7420 100644 --- a/.env +++ b/.env @@ -5,9 +5,8 @@ NGINX_SSL_ENABLED=false NGINX_PROTOCOL=http NGINX_HTTP_PORT=8080 NGINX_HTTPS_PORT=8443 -NGINX_MINIO_HOST=host.docker.internal -NGINX_API_HOST=host.docker.internal -NGINX_UI_HOST=host.docker.internal +# Set to 'localhost' or 'host.docker.internal' or '172.17.0.1' +NGINX_INTERNAL_HOST=host.docker.internal POSTGRES_HOST=localhost POSTGRES_USER=aviation @@ -27,11 +26,7 @@ MINIO_PORT=9000 MINIO_PORT_INTERNAL=9001 MINIO_BROWSER_REDIRECT_URL=${NGINX_PROTOCOL}://${NGINX_HOST}:${NGINX_HTTPS_PORT}/minio/ -UI_PROTOCOL=http UI_PORT=3000 - -API_PROTOCOL=http -API_HOST=0.0.0.0 API_PORT=5000 SSL_CA_NAME=ca diff --git a/api/src/main.rs b/api/src/main.rs index 1c47102..24d6481 100644 --- a/api/src/main.rs +++ b/api/src/main.rs @@ -70,7 +70,7 @@ async fn main() -> Result<(), Box> { .expect("Failed to create reqwest client"); let state = AppState { client }; - let host = env::var("API_HOST").unwrap_or("localhost".to_string()); + let host = "0.0.0.0"; let port = env::var("API_PORT").unwrap_or("5000".to_string()); let server = match HttpServer::new(move || { diff --git a/bruno/environments/Localhost.bru b/bruno/environments/Localhost.bru index 4fc287e..e845b2c 100644 --- a/bruno/environments/Localhost.bru +++ b/bruno/environments/Localhost.bru @@ -1,3 +1,4 @@ vars { - BASE_URL: https://localhost:8443 + ~BASE_URL: https://localhost:8443 + BASE_URL: http://localhost:8080 } diff --git a/docker-compose.yml b/docker-compose.yml index c716cfc..43a711f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -94,7 +94,6 @@ services: dockerfile: Dockerfile env_file: *env environment: - API_HOST: 0.0.0.0 SSL_CA_PATH: /ssl/ca.pem POSTGRES_HOST: aviation-postgres POSTGRES_PORT: 5432 diff --git a/nginx/templates/nossl.conf.template b/nginx/templates/nossl.conf.template index 2933860..327b849 100644 --- a/nginx/templates/nossl.conf.template +++ b/nginx/templates/nossl.conf.template @@ -5,7 +5,7 @@ server { server_name ${NGINX_HOST}; location /api/ { - proxy_pass ${API_PROTOCOL}://${NGINX_API_HOST}:${API_PORT}/api/; + proxy_pass http://${NGINX_INTERNAL_HOST}:${API_PORT}/api/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -13,7 +13,7 @@ server { } location /minio/ { - proxy_pass ${MINIO_PROTOCOL}://${NGINX_MINIO_HOST}:${MINIO_PORT_INTERNAL}/; + proxy_pass http://${NGINX_INTERNAL_HOST}:${MINIO_PORT_INTERNAL}/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -22,7 +22,7 @@ server { # Reverse proxy for the UI and default catch-all location / { - proxy_pass ${UI_PROTOCOL}://${NGINX_UI_HOST}:${UI_PORT}/; + proxy_pass http://${NGINX_INTERNAL_HOST}:${UI_PORT}/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; diff --git a/nginx/templates/ssl.conf.template b/nginx/templates/ssl.conf.template index 542014a..fa9b31f 100644 --- a/nginx/templates/ssl.conf.template +++ b/nginx/templates/ssl.conf.template @@ -25,7 +25,7 @@ server { # ssl_prefer_server_ciphers on; location /api/ { - proxy_pass ${API_PROTOCOL}://${NGINX_API_HOST}:${API_PORT}/api/; + proxy_pass http://${NGINX_INTERNAL_HOST}:${API_PORT}/api/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -33,7 +33,7 @@ server { } location /minio/ { - proxy_pass ${MINIO_PROTOCOL}://${NGINX_MINIO_HOST}:${MINIO_PORT_INTERNAL}/; + proxy_pass http://${NGINX_INTERNAL_HOST}:${MINIO_PORT_INTERNAL}/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; @@ -42,7 +42,7 @@ server { # Reverse proxy for the UI and default catch-all location / { - proxy_pass ${UI_PROTOCOL}://${NGINX_UI_HOST}:${UI_PORT}/; + proxy_pass http://${NGINX_INTERNAL_HOST}:${UI_PORT}/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;