5

I can't get any changes in the /etc/nginx/nginx.conf http block to be used. I'm starting with the simplest thing - I want to modify the name of access.log to something else (ie a.log). It is a vanilla nginx install (no custom config files yet). Here's what I know:

  • changing a value in the head of nginx.conf does affect the configuration (changing worker_processes 4 to worker_processes 2 does change the # of workers)
  • Making a syntax error in nginx.conf's http block does cause nginx to throw an error on restart
  • Changing access_log to access_log /var/log/nginx/a.log does not modify the location of the log, and nginx in fact continues logging to /var/log/nginx/access.log

Here is a snippet of my nginx.conf file:

user www-data;
worker_processes 4;
pid /run/nginx.pid;

events {
        worker_connections 768;
}

http {
        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        access_log /var/log/nginx/a.log;
        #....
}

Is it something as simple as I'm modifying an http block that gets overwritten by some other config file? Thanks for the help.

5
  • 1
    Try "grep -r /var/log/nginx/access.log /etc/nginx" and "grep -r include /etc/nginx". Commented Feb 14, 2015 at 18:33
  • A "vanilla" installation may vary depending on what distro you are using, but it could be some file like /etc/nginx/conf.d/default specifying how the default vhost should work. Commented Feb 14, 2015 at 18:34
  • "grep -r /var/log/nginx/access.log /etc/nginx" returns nothing and "grep -r include /etc/nginx" returns "/etc/nginx/nginx.conf: include /etc/nginx/mime.types; /etc/nginx/nginx.conf: #include /etc/nginx/naxsi_core.rules; /etc/nginx/nginx.conf: include /etc/nginx/conf.d/*.conf; /etc/nginx/nginx.conf: include /etc/nginx/sites-enabled/*;" Commented Feb 14, 2015 at 18:36
  • Thanks for the input. It's an ubuntu distro. No files in conf.d. Commented Feb 14, 2015 at 18:38
  • maybe you have a /etc/nginx/sites-enabled/default file then? Commented Feb 16, 2015 at 13:32

1 Answer 1

3

Isn't your access_log also defined in a server block ? Have a look at the default config in nginx/sites-enabled/. In this case the value in http block is overwritten by the one in the lower block.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I needed to put the change to the access log in the server block. To alter the format of the log, I had to put a log_format line in the nginx.conf http block and now everything is working as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.