[Fixes #1158] Split nginx logs by $APP

* nginx access logs to /var/log/nginx/${APP}-access.log
 * nginx error logs to /var/log/nginx/${APP}-error.log
This commit is contained in:
Andy Chambers
2015-05-24 23:53:24 -07:00
parent 3bf68616ad
commit eedb05d656
3 changed files with 24 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
# Nginx
Dokku uses nginx as it's server for routing requests to specific applications.
Dokku uses nginx as it's server for routing requests to specific applications. By default, access and error logs are written for each app to `/var/log/nginx/${APP}-access.log` and `/var/log/nginx/${APP}-error.log` respectively
## TLS/SPDY support
@@ -56,6 +56,8 @@ 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;

View File

@@ -2,6 +2,9 @@ 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;
location / {
proxy_pass http://$APP;
proxy_http_version 1.1;

View File

@@ -53,6 +53,18 @@ assert_http_success() {
assert_output "200"
}
assert_access_log() {
local prefix=$1
run [ -a /var/log/nginx/$prefix-access.log ]
assert_success
}
assert_error_log() {
local prefix=$1
run [ -a /var/log/nginx/$prefix-error.log ]
assert_success
}
@test "(nginx-vhosts) nginx (no server tokens)" {
deploy_app
run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | egrep '^Server' | egrep '[0-9]+'"
@@ -61,6 +73,12 @@ assert_http_success() {
assert_failure
}
@test "(nginx-vhosts) logging" {
deploy_app
assert_access_log ${TEST_APP}
assert_error_log ${TEST_APP}
}
@test "(nginx-vhosts) nginx:build-config (wildcard SSL)" {
setup_test_tls_wildcard
add_domain "wildcard1.dokku.me"