Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@danquack
Created November 1, 2018 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danquack/cc5d736af1378f6f17b9dd25bc30c0ac to your computer and use it in GitHub Desktop.
Save danquack/cc5d736af1378f6f17b9dd25bc30c0ac to your computer and use it in GitHub Desktop.
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