Created
November 1, 2018 03:44
-
-
Save danquack/cc5d736af1378f6f17b9dd25bc30c0ac to your computer and use it in GitHub Desktop.
Nginx Dynamic Config with Internal Domain DNS Resolution
This file contains 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
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