fix: Update nginx config to use dynamic DNS resolution
- Replace upstream blocks with resolver directive - Use variables for backend addresses to avoid startup errors - Simplify configuration with single server block - Add health check endpoint
This commit is contained in:
+22
-40
@@ -20,16 +20,10 @@ http {
|
||||
gzip_min_length 1024;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
|
||||
|
||||
# Upstream servers
|
||||
upstream gitea {
|
||||
server gitea:3000;
|
||||
}
|
||||
# Resolver for Docker DNS
|
||||
resolver 127.0.0.11 valid=30s;
|
||||
|
||||
upstream nanaxe_api {
|
||||
server nanaxe-api:8080;
|
||||
}
|
||||
|
||||
# HTTP server - redirects to HTTPS
|
||||
# Main server - serves static files and proxies to services
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
@@ -39,54 +33,42 @@ http {
|
||||
root /var/www/certbot;
|
||||
}
|
||||
|
||||
# Uncomment for HTTPS redirect
|
||||
# return 301 https://$server_name$request_uri;
|
||||
|
||||
# Or proxy to services for local development
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
# Health check endpoint
|
||||
location /health {
|
||||
access_log off;
|
||||
return 200 "healthy\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
}
|
||||
|
||||
# API Server
|
||||
server {
|
||||
listen 80;
|
||||
server_name api.*;
|
||||
|
||||
location / {
|
||||
proxy_pass http://nanaxe_api;
|
||||
# API proxy
|
||||
location /api/ {
|
||||
set $api_backend nanaxe-api:8080;
|
||||
proxy_pass http://$api_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
|
||||
# Timeouts
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_send_timeout 60s;
|
||||
proxy_read_timeout 60s;
|
||||
}
|
||||
}
|
||||
|
||||
# Gitea Server
|
||||
server {
|
||||
listen 80;
|
||||
server_name git.*;
|
||||
|
||||
location / {
|
||||
proxy_pass http://gitea;
|
||||
# Gitea proxy
|
||||
location /git/ {
|
||||
set $gitea_backend gitea:3000;
|
||||
proxy_pass http://$gitea_backend;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
# Default - static files
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user