Forum: NGINX Starting nginx: 2009/03/13 15:26:32 4382#0: unknown log format "main"

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D0a98f6304ff122ac9b487ff8275d8bb?d=identicon&s=25 Payam Chychi (Guest)
on 2009-03-13 23:38
(Received via mailing list)
Hi Guys,

Im using the latest nginx 4.
Here is the error that I am getting:

Starting nginx: 2009/03/13 15:19:55 [emerg] 4378#0: unknown log format
"main" in /etc/nginx/sites-enabled/p1/payam_70.33.253.5.conf:21


My Main nginx.conf config:

user  www-data;

worker_processes  4;

worker_rlimit_nofile 20480;



#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;



#pid        logs/nginx.pid;





events {

        use epoll;

    worker_connections 81920;

}



http {

    include    proxy.conf;

    include       mime.types;

    include /etc/nginx/sites-enabled/p1/*.conf;

    include /etc/nginx/sites-enabled/ypf/*.conf;



    default_type  application/octet-stream;



    log_format  main  '$remote_addr - $remote_user [$time_local]
"$request" '

                      '"$status" $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';



  sendfile        on;

  #tcp_nopush     on;

  tcp_nodelay        on;

  keepalive_timeout  45;



 ------------------------------------------#

# HTTP Server

# Default

#

     server {

        listen       x.x.x.x:80;

        server_name  nyc-fwmproxy-1;

  root /var/www;



         access_log      /var/log/nginx/nyc-fwmproxy-1.access_log main;

         error_log       /var/log/nginx/nyc-fwmproxy-1.error_log info;



         location / {

                        }





}

# ------------------------------------------#





}

# EOF




Here is my Config for "payam_70.33.253.5.conf":

# loadbalancers

# for the LB naming, include the ip address so its uniq



# HTTP LB

 upstream LB_HTTP_70.33.253.5 {

 server x.x.x.x:80 weight=3;

 server x.x.x.x:80;

 }



# HTTPS LB

 upstream LB_HTTPS_70.33.253.5 {

 server x.x.x.x:443;

 server x.x.x.x:443;

 }



# HTTP server

    server {

        listen       70.33.253.5:80;

        server_name  www.bhsecurity.com;



         access_log      /var/log/nginx/any.payam.access_log main;

         error_log       /var/log/nginx/any.payam.error_log info;



         location / {

         proxy_pass              http://LB_HTTP_70.33.253.5;

         }

}





# HTTPS server

    server {

        listen       70.33.253.5:443;

        server_name  www.bhsecurity.com;



         access_log      /var/log/nginx/any.payam.access_log main;

         error_log       /var/log/nginx/any.payam.error_log info;



         ssl                  on;

         ssl_certificate
/etc/nginx/sites-enabled/ssl/ypf/payam/payam.crt;

         ssl_certificate_key
/etc/nginx/sites-enabled/ssl/ypf/payam/payam.key;



         location / {

         proxy_pass             https://LB_HTTPS_70.33.253.5;

         }

}



What am i doing wrong here? any help would greatly be appreciated
Thanks,
Payam
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2009-03-14 12:16
(Received via mailing list)
Hello!

On Fri, Mar 13, 2009 at 03:26:50PM -0700, Payam Chychi wrote:

> Im using the latest nginx 4.
> Here is the error that I am getting:
>
> Starting nginx: 2009/03/13 15:19:55 [emerg] 4378#0: unknown log format
> "main" in /etc/nginx/sites-enabled/p1/payam_70.33.253.5.conf:21
>
>
> My Main nginx.conf config:
>
> user  www-data;

[...]

> http {
>
>     include    proxy.conf;
>
>     include       mime.types;
>
>     include /etc/nginx/sites-enabled/p1/*.conf;
>
>     include /etc/nginx/sites-enabled/ypf/*.conf;

Includes with servers{} using log_format main are above definition
of log_format.  You should move them below.

[...]

>     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
>
>                       '"$status" $body_bytes_sent "$http_referer" '
>
>                       '"$http_user_agent" "$http_x_forwarded_for"';

[...]

Maxim Dounin
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-03-14 17:06
(Received via mailing list)
On Fri, Mar 13, 2009 at 03:26:50PM -0700, Payam Chychi wrote:

>
> #error_log  logs/error.log  notice;
>
> http {
>
>     default_type  application/octet-stream;
>
>
>
>     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
>
>                       '"$status" $body_bytes_sent "$http_referer" '
>
>                       '"$http_user_agent" "$http_x_forwarded_for"';

You need to set log_format before

     include /etc/nginx/sites-enabled/p1/*.conf;

     include /etc/nginx/sites-enabled/ypf/*.conf;
This topic is locked and can not be replied to.