2016-04-21 70 views
1

我堅持以下的nginx的conf模板工作:的Nginx的conf模板不dokku

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

的dokku文檔告訴我逃脫「$」與單個\,所以我這樣做。

nginx wiz可以告訴nginx n00b上述模板有什麼問題嗎?

Dokku輸出下列錯誤:

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

謝謝!

回答

1

線:

access_log logs/internal_redirect.access.log main; 

假定有一個log_format指令,它指定一個main格式。默認情況下,nginx提供combined格式。

要麼與替換上面的行:

access_log logs/internal_redirect.access.log combined; 

或定義log_format main

查看this document瞭解詳情。

+0

謝謝!進行編輯。現在我有一個不同的錯誤:[emerg]在/home/dokku/everseller/nginx.conf:117的「set」指令中無效的參數個數。什麼是n00b要做的? :-) – Corstiaan

+0

@Corstiaan你的'set'指令中有一些非轉義的'$'。 –

+0

我們正在某處:-)。但是,沒有我得到這個錯誤:[emerg]在/home/dokku/everseller/nginx.conf:96中的「proxy_set_header」指令中無效的參數數量。您懷疑哪個電話是proxy_set_header是罪魁禍首? – Corstiaan