Nginx fails to start HTTP/2 server due to error: unknown log format





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}






up vote
2
down vote

favorite












In our hosting server from the Plesk cpanel, Nginx is configured to work as a reverse proxy engine. As I need to enable HTTP/2 that can speed up the loading time of Plesk and hosted websites.
Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory



When I tried to enable HTTP/2 from GUI it gave the error as:




[2018-11-15 10:47:29.068] ERR [util_exec] proc_close() failed
['/opt/psa/admin/bin/nginx_control' '--start'] with exit code [1] Can
not start proxy server: /opt/psa/admin/sbin/nginx-config execution
failed: nginx: [emerg] unknown log format "main" in
/etc/nginx/nginx.conf:26 nginx: configuration file
/etc/nginx/nginx.conf test failed




Here is my configuration of nginx.conf file



#user  nginx;
worker_processes 1;

error_log /var/log/nginx/error.log;
error_log /var/log/nginx/error.log notice;
error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
worker_connections 1024;
}


http {
include mime.types;
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"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;

#gzip on;
#gzip_disable "MSIE [1-6].(?!.*SV1)";

server_tokens off;

include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;


How do we Enable HTTP/2










share|improve this question






























    up vote
    2
    down vote

    favorite












    In our hosting server from the Plesk cpanel, Nginx is configured to work as a reverse proxy engine. As I need to enable HTTP/2 that can speed up the loading time of Plesk and hosted websites.
    Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory



    When I tried to enable HTTP/2 from GUI it gave the error as:




    [2018-11-15 10:47:29.068] ERR [util_exec] proc_close() failed
    ['/opt/psa/admin/bin/nginx_control' '--start'] with exit code [1] Can
    not start proxy server: /opt/psa/admin/sbin/nginx-config execution
    failed: nginx: [emerg] unknown log format "main" in
    /etc/nginx/nginx.conf:26 nginx: configuration file
    /etc/nginx/nginx.conf test failed




    Here is my configuration of nginx.conf file



    #user  nginx;
    worker_processes 1;

    error_log /var/log/nginx/error.log;
    error_log /var/log/nginx/error.log notice;
    error_log /var/log/nginx/error.log info;

    #pid /var/run/nginx.pid;

    include /etc/nginx/modules.conf.d/*.conf;

    events {
    worker_connections 1024;
    }


    http {
    include mime.types;
    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"';

    access_log /var/log/nginx/access.log main;

    sendfile on;
    #tcp_nopush on;

    #keepalive_timeout 0;
    keepalive_timeout 65;
    #tcp_nodelay on;

    #gzip on;
    #gzip_disable "MSIE [1-6].(?!.*SV1)";

    server_tokens off;

    include /etc/nginx/conf.d/*.conf;
    }

    # override global parameters e.g. worker_rlimit_nofile
    include /etc/nginx/*global_params;


    How do we Enable HTTP/2










    share|improve this question


























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      In our hosting server from the Plesk cpanel, Nginx is configured to work as a reverse proxy engine. As I need to enable HTTP/2 that can speed up the loading time of Plesk and hosted websites.
      Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory



      When I tried to enable HTTP/2 from GUI it gave the error as:




      [2018-11-15 10:47:29.068] ERR [util_exec] proc_close() failed
      ['/opt/psa/admin/bin/nginx_control' '--start'] with exit code [1] Can
      not start proxy server: /opt/psa/admin/sbin/nginx-config execution
      failed: nginx: [emerg] unknown log format "main" in
      /etc/nginx/nginx.conf:26 nginx: configuration file
      /etc/nginx/nginx.conf test failed




      Here is my configuration of nginx.conf file



      #user  nginx;
      worker_processes 1;

      error_log /var/log/nginx/error.log;
      error_log /var/log/nginx/error.log notice;
      error_log /var/log/nginx/error.log info;

      #pid /var/run/nginx.pid;

      include /etc/nginx/modules.conf.d/*.conf;

      events {
      worker_connections 1024;
      }


      http {
      include mime.types;
      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"';

      access_log /var/log/nginx/access.log main;

      sendfile on;
      #tcp_nopush on;

      #keepalive_timeout 0;
      keepalive_timeout 65;
      #tcp_nodelay on;

      #gzip on;
      #gzip_disable "MSIE [1-6].(?!.*SV1)";

      server_tokens off;

      include /etc/nginx/conf.d/*.conf;
      }

      # override global parameters e.g. worker_rlimit_nofile
      include /etc/nginx/*global_params;


      How do we Enable HTTP/2










      share|improve this question















      In our hosting server from the Plesk cpanel, Nginx is configured to work as a reverse proxy engine. As I need to enable HTTP/2 that can speed up the loading time of Plesk and hosted websites.
      Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory



      When I tried to enable HTTP/2 from GUI it gave the error as:




      [2018-11-15 10:47:29.068] ERR [util_exec] proc_close() failed
      ['/opt/psa/admin/bin/nginx_control' '--start'] with exit code [1] Can
      not start proxy server: /opt/psa/admin/sbin/nginx-config execution
      failed: nginx: [emerg] unknown log format "main" in
      /etc/nginx/nginx.conf:26 nginx: configuration file
      /etc/nginx/nginx.conf test failed




      Here is my configuration of nginx.conf file



      #user  nginx;
      worker_processes 1;

      error_log /var/log/nginx/error.log;
      error_log /var/log/nginx/error.log notice;
      error_log /var/log/nginx/error.log info;

      #pid /var/run/nginx.pid;

      include /etc/nginx/modules.conf.d/*.conf;

      events {
      worker_connections 1024;
      }


      http {
      include mime.types;
      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"';

      access_log /var/log/nginx/access.log main;

      sendfile on;
      #tcp_nopush on;

      #keepalive_timeout 0;
      keepalive_timeout 65;
      #tcp_nodelay on;

      #gzip on;
      #gzip_disable "MSIE [1-6].(?!.*SV1)";

      server_tokens off;

      include /etc/nginx/conf.d/*.conf;
      }

      # override global parameters e.g. worker_rlimit_nofile
      include /etc/nginx/*global_params;


      How do we Enable HTTP/2







      https http nginx plesk reverse-proxy






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 15 at 9:22









      Stephen Ostermiller

      65.9k1389238




      65.9k1389238










      asked Nov 15 at 5:49









      Nishanth ॐ

      2317




      2317






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          The main reason for the failure was that I had explicitly commented out log_format main.



          Configuring Access Logs in Nginx
          Under Nginx, all client requests to the server are recorded in the access log in a specified format using the ngx_http_log_module module.



          The default log file is log/access.log (usually /var/log/nginx/access_log on Linux systems) and the default format for logging is normally the combined or main format (this can vary from one distro to another).



          The access_log directive (applicable in the HTTP, server, location, if in location and limit except for context) is used to set the log file and the log_format directive (applicable under the HTTP context only) is used to set the log format. The log format is described by common variables and variables that generated only at the time when a log is written.



          The syntax for configuring a log format is:



          log_format format_name 'set_of_variables_to_define_format';





          /etc/ngnix/ngnix.conf

          #user  nginx;
          worker_processes 1;

          error_log /var/log/nginx/error.log;
          error_log /var/log/nginx/error.log notice;
          error_log /var/log/nginx/error.log info;

          #pid /var/run/nginx.pid;

          include /etc/nginx/modules.conf.d/*.conf;

          events {
          worker_connections 1024;
          }


          http {
          include mime.types;
          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"';

          access_log /var/log/nginx/access.log main;

          sendfile on;
          #tcp_nopush on;

          #keepalive_timeout 0;
          keepalive_timeout 65;
          #tcp_nodelay on;

          #gzip on;
          #gzip_disable "MSIE [1-6].(?!.*SV1)";

          server_tokens off;

          include /etc/nginx/conf.d/*.conf;
          }

          # override global parameters e.g. worker_rlimit_nofile
          include /etc/nginx/*global_params;


          It worked



          "Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory" - This statement is wrong. The relevant part is not if HTTP/2 is enabled at the server but if the URL is http:// or https://. In the first case, it will use plain HTTP/1.1, in the second case HTTP/1.1 or HTTP/2 over TLS depending on what the server supports.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "45"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwebmasters.stackexchange.com%2fquestions%2f119062%2fnginx-fails-to-start-http-2-server-due-to-error-unknown-log-format%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            The main reason for the failure was that I had explicitly commented out log_format main.



            Configuring Access Logs in Nginx
            Under Nginx, all client requests to the server are recorded in the access log in a specified format using the ngx_http_log_module module.



            The default log file is log/access.log (usually /var/log/nginx/access_log on Linux systems) and the default format for logging is normally the combined or main format (this can vary from one distro to another).



            The access_log directive (applicable in the HTTP, server, location, if in location and limit except for context) is used to set the log file and the log_format directive (applicable under the HTTP context only) is used to set the log format. The log format is described by common variables and variables that generated only at the time when a log is written.



            The syntax for configuring a log format is:



            log_format format_name 'set_of_variables_to_define_format';





            /etc/ngnix/ngnix.conf

            #user  nginx;
            worker_processes 1;

            error_log /var/log/nginx/error.log;
            error_log /var/log/nginx/error.log notice;
            error_log /var/log/nginx/error.log info;

            #pid /var/run/nginx.pid;

            include /etc/nginx/modules.conf.d/*.conf;

            events {
            worker_connections 1024;
            }


            http {
            include mime.types;
            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"';

            access_log /var/log/nginx/access.log main;

            sendfile on;
            #tcp_nopush on;

            #keepalive_timeout 0;
            keepalive_timeout 65;
            #tcp_nodelay on;

            #gzip on;
            #gzip_disable "MSIE [1-6].(?!.*SV1)";

            server_tokens off;

            include /etc/nginx/conf.d/*.conf;
            }

            # override global parameters e.g. worker_rlimit_nofile
            include /etc/nginx/*global_params;


            It worked



            "Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory" - This statement is wrong. The relevant part is not if HTTP/2 is enabled at the server but if the URL is http:// or https://. In the first case, it will use plain HTTP/1.1, in the second case HTTP/1.1 or HTTP/2 over TLS depending on what the server supports.






            share|improve this answer



























              up vote
              2
              down vote













              The main reason for the failure was that I had explicitly commented out log_format main.



              Configuring Access Logs in Nginx
              Under Nginx, all client requests to the server are recorded in the access log in a specified format using the ngx_http_log_module module.



              The default log file is log/access.log (usually /var/log/nginx/access_log on Linux systems) and the default format for logging is normally the combined or main format (this can vary from one distro to another).



              The access_log directive (applicable in the HTTP, server, location, if in location and limit except for context) is used to set the log file and the log_format directive (applicable under the HTTP context only) is used to set the log format. The log format is described by common variables and variables that generated only at the time when a log is written.



              The syntax for configuring a log format is:



              log_format format_name 'set_of_variables_to_define_format';





              /etc/ngnix/ngnix.conf

              #user  nginx;
              worker_processes 1;

              error_log /var/log/nginx/error.log;
              error_log /var/log/nginx/error.log notice;
              error_log /var/log/nginx/error.log info;

              #pid /var/run/nginx.pid;

              include /etc/nginx/modules.conf.d/*.conf;

              events {
              worker_connections 1024;
              }


              http {
              include mime.types;
              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"';

              access_log /var/log/nginx/access.log main;

              sendfile on;
              #tcp_nopush on;

              #keepalive_timeout 0;
              keepalive_timeout 65;
              #tcp_nodelay on;

              #gzip on;
              #gzip_disable "MSIE [1-6].(?!.*SV1)";

              server_tokens off;

              include /etc/nginx/conf.d/*.conf;
              }

              # override global parameters e.g. worker_rlimit_nofile
              include /etc/nginx/*global_params;


              It worked



              "Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory" - This statement is wrong. The relevant part is not if HTTP/2 is enabled at the server but if the URL is http:// or https://. In the first case, it will use plain HTTP/1.1, in the second case HTTP/1.1 or HTTP/2 over TLS depending on what the server supports.






              share|improve this answer

























                up vote
                2
                down vote










                up vote
                2
                down vote









                The main reason for the failure was that I had explicitly commented out log_format main.



                Configuring Access Logs in Nginx
                Under Nginx, all client requests to the server are recorded in the access log in a specified format using the ngx_http_log_module module.



                The default log file is log/access.log (usually /var/log/nginx/access_log on Linux systems) and the default format for logging is normally the combined or main format (this can vary from one distro to another).



                The access_log directive (applicable in the HTTP, server, location, if in location and limit except for context) is used to set the log file and the log_format directive (applicable under the HTTP context only) is used to set the log format. The log format is described by common variables and variables that generated only at the time when a log is written.



                The syntax for configuring a log format is:



                log_format format_name 'set_of_variables_to_define_format';





                /etc/ngnix/ngnix.conf

                #user  nginx;
                worker_processes 1;

                error_log /var/log/nginx/error.log;
                error_log /var/log/nginx/error.log notice;
                error_log /var/log/nginx/error.log info;

                #pid /var/run/nginx.pid;

                include /etc/nginx/modules.conf.d/*.conf;

                events {
                worker_connections 1024;
                }


                http {
                include mime.types;
                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"';

                access_log /var/log/nginx/access.log main;

                sendfile on;
                #tcp_nopush on;

                #keepalive_timeout 0;
                keepalive_timeout 65;
                #tcp_nodelay on;

                #gzip on;
                #gzip_disable "MSIE [1-6].(?!.*SV1)";

                server_tokens off;

                include /etc/nginx/conf.d/*.conf;
                }

                # override global parameters e.g. worker_rlimit_nofile
                include /etc/nginx/*global_params;


                It worked



                "Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory" - This statement is wrong. The relevant part is not if HTTP/2 is enabled at the server but if the URL is http:// or https://. In the first case, it will use plain HTTP/1.1, in the second case HTTP/1.1 or HTTP/2 over TLS depending on what the server supports.






                share|improve this answer














                The main reason for the failure was that I had explicitly commented out log_format main.



                Configuring Access Logs in Nginx
                Under Nginx, all client requests to the server are recorded in the access log in a specified format using the ngx_http_log_module module.



                The default log file is log/access.log (usually /var/log/nginx/access_log on Linux systems) and the default format for logging is normally the combined or main format (this can vary from one distro to another).



                The access_log directive (applicable in the HTTP, server, location, if in location and limit except for context) is used to set the log file and the log_format directive (applicable under the HTTP context only) is used to set the log format. The log format is described by common variables and variables that generated only at the time when a log is written.



                The syntax for configuring a log format is:



                log_format format_name 'set_of_variables_to_define_format';





                /etc/ngnix/ngnix.conf

                #user  nginx;
                worker_processes 1;

                error_log /var/log/nginx/error.log;
                error_log /var/log/nginx/error.log notice;
                error_log /var/log/nginx/error.log info;

                #pid /var/run/nginx.pid;

                include /etc/nginx/modules.conf.d/*.conf;

                events {
                worker_connections 1024;
                }


                http {
                include mime.types;
                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"';

                access_log /var/log/nginx/access.log main;

                sendfile on;
                #tcp_nopush on;

                #keepalive_timeout 0;
                keepalive_timeout 65;
                #tcp_nodelay on;

                #gzip on;
                #gzip_disable "MSIE [1-6].(?!.*SV1)";

                server_tokens off;

                include /etc/nginx/conf.d/*.conf;
                }

                # override global parameters e.g. worker_rlimit_nofile
                include /etc/nginx/*global_params;


                It worked



                "Additionally, using HTTP/2 is more secure because it makes TLS connections mandatory" - This statement is wrong. The relevant part is not if HTTP/2 is enabled at the server but if the URL is http:// or https://. In the first case, it will use plain HTTP/1.1, in the second case HTTP/1.1 or HTTP/2 over TLS depending on what the server supports.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Nov 15 at 9:25









                Stephen Ostermiller

                65.9k1389238




                65.9k1389238










                answered Nov 15 at 6:43









                Nishanth ॐ

                2317




                2317






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwebmasters.stackexchange.com%2fquestions%2f119062%2fnginx-fails-to-start-http-2-server-due-to-error-unknown-log-format%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Plaza Victoria

                    Puebla de Zaragoza

                    Musa