Nginx conf template não funciona com dokku

1

Estou preso ao seguinte modelo de conf nginx:

# Special characters - dollar signs, spaces inside of quotes, etc. -
# should be escaped with a single backslash or can cause deploy failures.

server {
    listen      [::]:80;
    listen      80;
    server_name $NOSSL_SERVER_NAME;
    access_log  /var/log/nginx/${APP}-access.log;
    error_log   /var/log/nginx/${APP}-error.log;

    # set a custom header for requests
    # add_header X-Served-By www-ec2-01;

    location    / {
      proxy_pass  http://$APP;
      proxy_http_version 1.1;
      proxy_set_header Upgrade \$http_upgrade;
      proxy_set_header Connection "upgrade";
      proxy_set_header Host \$http_host;
      proxy_set_header X-Forwarded-Proto \$scheme;
      proxy_set_header X-Forwarded-For \$remote_addr;
      proxy_set_header X-Forwarded-Port \$server_port;
      proxy_set_header X-Request-Start \$msec;
    }

    include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;

    # Proxy download 
    location ~* ^/internal_redirect/(.*?)/(.*) {
    # Do not allow people to mess with this location directly
    # Only internal redirects are allowed
    internal;

    # Location-specific logging
    access_log logs/internal_redirect.access.log main;
    error_log logs/internal_redirect.error.log warn;

    # Extract download url from the request
    set $download_uri \;
    set $download_host \;

    # Compose download url
    set $download_url http://\$download_host/\$download_uri;

    # Set download request headers
    proxy_set_header Host \$download_host;
    proxy_set_header Authorization '';

    # The next two lines could be used if your storage 
    # backend does not support Content-Disposition 
    # headers used to specify file name browsers use 
    # when save content to the disk
    proxy_hide_header Content-Disposition;
    add_header Content-Disposition 'attachment; filename="\$args"';

    # Do not touch local disks when proxying 
    # content to clients
    proxy_max_temp_file_size 0;

    # Download the file and send it to client
    proxy_pass \$download_url;
  }
}

Os documentos dokku me dizem para escapar de '$' com um único \, então eu fiz isso.

Um nginx wiz pode dizer a um nginx n00b o que há de errado com o modelo acima?

Dokku gera o seguinte erro:

remote: nginx: [emerg] unknown log format "main" in /home/dokku/everseller/nginx.conf:117
remote: nginx: configuration file /etc/nginx/nginx.conf test failed

Obrigado!

==== conf atualizado ====

# Special characters - dollar signs, spaces inside of quotes, etc. -
# should be escaped with a single backslash or can cause deploy failures.

server {
  listen      [::]:80;
  listen      80;
  server_name $NOSSL_SERVER_NAME;
  access_log  /var/log/nginx/${APP}-access.log;
  error_log   /var/log/nginx/${APP}-error.log;

  # set a custom header for requests
  # add_header X-Served-By www-ec2-01;

  location    / {
    proxy_pass  http://$APP;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Request-Start $msec;
  }

  include $DOKKU_ROOT/$APP/nginx.conf.d/*.conf;

  # Proxy download 
  location ~* ^/internal_redirect/(.*?)/(.*) {
  # Do not allow people to mess with this location directly
  # Only internal redirects are allowed
  internal;

  # Location-specific logging
  access_log logs/internal_redirect.access.log main;
  error_log logs/internal_redirect.error.log warn;

  # Extract download url from the request
  set $download_uri $2;
  set $download_host $1;

  # Compose download url
  set $download_url http://$download_host/$download_uri;

  # Set download request headers
  proxy_set_header Host $download_host;
  proxy_set_header Authorization '';

  # The next two lines could be used if your storage 
  # backend does not support Content-Disposition 
  # headers used to specify file name browsers use 
  # when save content to the disk
  proxy_hide_header Content-Disposition;
  add_header Content-Disposition 'attachment; filename="$args"';

  # Do not touch local disks when proxying 
  # content to clients
  proxy_max_temp_file_size 0;

  # Download the file and send it to client
  proxy_pass $download_url;
    }
}
    
por Corstiaan 21.04.2016 / 16:01

1 resposta

0

Cifrões indicam variáveis. Então, se usado em algum lugar não indicando uma variável, eles devem ser escapados.

Sua configuração contém muitas variáveis, nas quais os sinais de cifrão não devem ser ignorados, por exemplo, proxy_set_header Upgrade \$http_upgrade;
deve ser proxy_set_header Upgrade $http_upgrade;

proxy_set_header Host \$http_host; deve ler proxy_set_header Host $http_host; e assim por diante.

A propósito: eu não sou um wiz; -)

    
por 21.04.2016 / 16:17

Tags