Created
November 22, 2024 03:53
-
-
Save keyboardcrunch/f5fd782306aeff0ee124fc3e9822655a to your computer and use it in GitHub Desktop.
Nginx wildcard subdomain, map and upstream example
This file contains hidden or 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
# Setup an "upstream" to allow preferences between local or tailscale endpoints for an Ollama service | |
# Note: I'm running a similar config on my laptop so I can access services while local or remote but | |
# use upstream to pick the endpoint to use. | |
upstream chat { | |
ip_hash; | |
server 192.168.1.3:11434; | |
server 100.44.39.165:11434; | |
} | |
# Setup a map to associate our proxy endpoint with the subdomain | |
map $subdomain $prxy { | |
video http://192.168.1.6:8080; | |
chat http://chat; # This is our upstream reference | |
} | |
server { | |
# Match on the subdomain for our website.net domain | |
server_name ~^(?<subdomain>\w+)\.website\.net$; | |
# Proxy subdomain matches and include url paramaters | |
location / { | |
proxy_pass $prxy; | |
include proxy_params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Still need to do a few things to clean up formatting, handle errors better, and ensure letsencrypt/certbot compatibility.