Merge pull request #1210 from cddr/split-nginx-logs

[Fixes #1158] Split nginx logs by $APP
This commit is contained in:
Jose Diaz-Gonzalez
2015-05-25 23:23:52 -04:00
3 changed files with 24 additions and 1 deletions

View File

@@ -1,6 +1,6 @@
# Nginx # 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 ## TLS/SPDY support
@@ -56,6 +56,8 @@ server {
listen [::]:80; listen [::]:80;
listen 80; listen 80;
server_name $NOSSL_SERVER_NAME; 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 # set a custom header for requests
add_header X-Served-By www-ec2-01; add_header X-Served-By www-ec2-01;

View File

@@ -2,6 +2,9 @@ server {
listen [::]:80; listen [::]:80;
listen 80; listen 80;
server_name $NOSSL_SERVER_NAME; server_name $NOSSL_SERVER_NAME;
access_log /var/log/nginx/${APP}-access.log;
error_log /var/log/nginx/${APP}-error.log;
location / { location / {
proxy_pass http://$APP; proxy_pass http://$APP;
proxy_http_version 1.1; proxy_http_version 1.1;

View File

@@ -53,6 +53,18 @@ assert_http_success() {
assert_output "200" 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)" { @test "(nginx-vhosts) nginx (no server tokens)" {
deploy_app deploy_app
run /bin/bash -c "curl -s -D - $(dokku url $TEST_APP) -o /dev/null | egrep '^Server' | egrep '[0-9]+'" 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 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)" { @test "(nginx-vhosts) nginx:build-config (wildcard SSL)" {
setup_test_tls_wildcard setup_test_tls_wildcard
add_domain "wildcard1.dokku.me" add_domain "wildcard1.dokku.me"