Skip to content

Instantly share code, notes, and snippets.

@iamrommel
Created December 11, 2018 12:55
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 iamrommel/4236cb7796defc40aeb2c2a9edcc05bf to your computer and use it in GitHub Desktop.
Save iamrommel/4236cb7796defc40aeb2c2a9edcc05bf to your computer and use it in GitHub Desktop.
<%
if (s.forceSsl) {
%>
server {
listen 80;
server_name <%-s.publicDomain%>;
# Used by Let's Encrypt
location /.well-known/ {
root <%-s.staticWebRoot%>;
}
location / {
return 302 https://$http_host$request_uri$is_args$query_string;
}
}
<%
}
%>
<%
if (!s.forceSsl || s.hasSsl) {
%>
server {
<%
if (!s.forceSsl) {
%>
listen 80;
<%
}
if (s.hasSsl) {
%>
listen 443 ssl;
ssl_certificate <%-s.crtPath%>;
ssl_certificate_key <%-s.keyPath%>;
<%
}
%>
client_max_body_size 500m;
server_name <%-s.publicDomain%>;
# 127.0.0.11 is DNS set up by Docker, see:
# https://docs.docker.com/engine/userguide/networking/configure-dns/
# https://github.com/moby/moby/issues/20026
resolver 127.0.0.11 valid=10s;
set $upstream http://<%-s.localDomain%>:5984;
location / {
proxy_pass $upstream;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ ^/(.*)/_changes {
proxy_pass $upstream;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /.well-known/ {
root <%-s.staticWebRoot%>;
}
}
<%
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment