Nginx conf template not working with dokku

I am stuck with the following nginx conf template:

# 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;
  }
}

The dokku docs tell me to escape ‘$’ with a single \, so I did that.

  • Docker: Strider CD dashboard assets broken on installation
  • Execute script inside docker container which is folder different than WORKDIR
  • Docker on bare metal (with some form of hypervisor) vs. on full fledged Linux distribution
  • Upgrade of Docker from Swarm to Swarm Mode - is recreation of containers needed?
  • Use host networking and additional networks in docker compose
  • How to get ip and port in one docker container form other one with environment variables?
  • Can a nginx wiz tell a nginx n00b what is wrong with the above template?

    Dokku outputs the following error:

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

    Thanks!

  • How to install and run postgress using docker-compose.yml version “1”
  • How do you manage per-environment data in Docker-based microservices?
  • Cannot kill pid 1 inside docker container with SIGKILL
  • bin//sonar-scanner: 103: exec: : Permission denied
  • gdb in docker container returns “ptrace: Operation not permitted.”
  • Provide environment variables to elastic beanstalk docker deployment
  • One Solution collect form web for “Nginx conf template not working with dokku”

    The line:

    access_log logs/internal_redirect.access.log main;
    

    assumes that there is a log_format directive which specifies a main format. By default nginx provides a combined format.

    Either replace the above line with:

    access_log logs/internal_redirect.access.log combined;
    

    Or define a log_format main.

    See this document for details.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.