Files
password_generator/nginx.conf
2026-03-24 21:43:57 -07:00

44 lines
2.1 KiB
Nginx Configuration File

# /etc/nginx/conf.d/default.conf
# This file is mounted into the container at the same location.
# ------------------------------------------------------------------
# 1. Common proxy-headers (set once, use everywhere)
# ------------------------------------------------------------------
# These are forwarded to *every* upstream that Nginx talks to.
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;
# ------------------------------------------------------------------
# 2. Server block
# ------------------------------------------------------------------
server {
listen 80 default_server;
server_name _; # Catch-all - change to your domain if you need a specific name.
# ------------------------------------------------------------------
# 3. API routes - all hit the same Flask app (localhost:5000)
# ------------------------------------------------------------------
# A single location with a regex is cleaner than five almost-identical
# blocks. The regex matches the exact paths you listed.
location ~ ^/(get_password|verbose_password|custom_password|get_count|get_info)$ {
proxy_pass http://localhost:5000; # Forward *exactly* the same URI
proxy_redirect off; # Preserve any redirects from Flask
}
# ------------------------------------------------------------------
# 4. All other requests go to Apache/PHP (localhost:8080)
# ------------------------------------------------------------------
location / {
proxy_pass http://localhost:8080;
proxy_redirect off; # (optional but safe)
}
# ------------------------------------------------------------------
# 5. Optional timeout tuning - adjust to your workload
# ------------------------------------------------------------------
proxy_connect_timeout 10s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
}