Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nginx Dynamic Config with Internal Domain DNS Resolution
server {
listen 80;
server_name *.<%= @domain %>;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name <%= @domain %>;
ssl_certificate /etc/letsencrypt/live/<%= @domain %>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<%= @domain %>/privkey.pem;
location / {
resolver 192.168.1.1;
proxy_pass http://admin;
}
}
server {
listen 443 ssl http2;
server_name *.<%= @domain %>;
ssl_certificate /etc/letsencrypt/live/<%= @domain %>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<%= @domain %>/privkey.pem;
if ($host ~* ^(www\.)?([^.]+).<%= @domain %>$) {
set $subdomain $2;
}
location / {
resolver 192.168.1.1;
proxy_pass https://$subdomain.<%= @internaldomain %>;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment