diff --git a/docs/deployment/ssl-configuration.md b/docs/deployment/ssl-configuration.md index 8a31dfcf2..b20aedf54 100644 --- a/docs/deployment/ssl-configuration.md +++ b/docs/deployment/ssl-configuration.md @@ -84,12 +84,6 @@ Your application has access to the HTTP headers `X-Forwarded-Proto`, `X-Forwarde If your server runs behind an HTTP/S load balancer, then Nginx will see all requests as coming from the load balancer. If your load balancer sets the `X-Forwarded-` headers, you can tell Nginx to pass these headers from load balancer to your application by using the following [nginx custom template](/dokku/nginx/#customizing-the-nginx-configuration) ```shell -upstream {{ .APP }} { -{{ range .DOKKU_APP_LISTENERS | split " " }} - server {{ . }}; -{{ end }} -} - server { listen [::]:{{ .NGINX_PORT }}; listen {{ .NGINX_PORT }}; @@ -113,6 +107,12 @@ server { } include {{ .DOKKU_ROOT }}/{{ .APP }}/nginx.conf.d/*.conf; } + +upstream {{ .APP }} { +{{ range .DOKKU_APP_LISTENERS | split " " }} + server {{ . }}; +{{ end }} +} ``` Only use this option if: diff --git a/docs/nginx.md b/docs/nginx.md index 231f97c9a..d7c4bb3e9 100644 --- a/docs/nginx.md +++ b/docs/nginx.md @@ -25,11 +25,6 @@ Dokku uses a templating library by the name of [sigil](https://github.com/glider Use case: add an `X-Served-By` header to requests ``` -upstream {{ .APP }} { -{{ range .DOKKU_APP_LISTENERS | split " " }} - server {{ . }}; -{{ end }} -} server { listen [::]:{{ .NGINX_PORT }}; listen {{ .NGINX_PORT }}; @@ -39,7 +34,7 @@ server { # set a custom header for requests add_header X-Served-By www-ec2-01; - + gzip on; gzip_min_length 1100; gzip_buffers 4 32k; @@ -60,6 +55,12 @@ server { } include {{ .DOKKU_ROOT }}/{{ .APP }}/nginx.conf.d/*.conf; } + +upstream {{ .APP }} { +{{ range .DOKKU_APP_LISTENERS | split " " }} + server {{ . }}; +{{ end }} +} ``` ### Available template variables @@ -82,11 +83,6 @@ server { ### Example HTTP to HTTPS Custom Template Use case: a simple dockerfile app that includes `EXPOSE 80` ``` -upstream {{ .APP }} { -{{ range .DOKKU_APP_LISTENERS | split " " }} - server {{ . }}; -{{ end }} -} server { listen [::]:80; listen 80; @@ -123,6 +119,12 @@ server { } include {{ .DOKKU_ROOT }}/{{ .APP }}/nginx.conf.d/*.conf; } + +upstream {{ .APP }} { +{{ range .DOKKU_APP_LISTENERS | split " " }} + server {{ . }}; +{{ end }} +} ``` ### Customizing via configuration files included by the default templates