Score:0

nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:49

jp flag

Iam facing with this error,

Starting nginx: nginx: [emerg] "location" directive is not allowed here in /etc/nginx/nginx.conf:49 nginx: configuration file /etc/nginx/nginx.conf test failed

This is my nginx.conf file:

For more information on configuration, see:

  2 #   * Official English Documentation: http://nginx.org/en/docs/
  3 #   * Official Russian Documentation: http://nginx.org/ru/docs/
  4
  5 user nginx;
  6 worker_processes auto;
  7 error_log /var/log/nginx/error.log;
  8 pid /run/nginx.pid;
  9
 10 # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
 11 include /usr/share/nginx/modules/*.conf;
 12
 13 events {
 14     worker_connections 1024;
 15 }
 16
 17 http {
 18     log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 19                       '$status $body_bytes_sent "$http_referer" '
 20                       '"$http_user_agent" "$http_x_forwarded_for"';
 21
 22     access_log  /var/log/nginx/access.log  main;
 23
 24     sendfile            on;
 25     tcp_nopush          on;
 26     tcp_nodelay         on;
 27     keepalive_timeout   65;
 28     types_hash_max_size 4096;
 29
 30     include             /etc/nginx/mime.types;
 31     default_type        application/octet-stream;
 32
 33     # Load modular configuration files from the /etc/nginx/conf.d directory.
 34     # See http://nginx.org/en/docs/ngx_core_module.html#include
 35     # for more information.
 36     include /etc/nginx/conf.d/*.conf;
 37     include /etc/nginx/sites-enabled/*.conf;
 38
 39     # server {
 40     #     listen       80;
 41     #    listen       [::]:80;
 42     #    server_name  _;
 43     #    root         /usr/share/nginx/html;
 44
 45         # Load configuration files for the default server block.
 46         include /etc/nginx/default.d/*.conf;
 47
 48         error_page 404 /404.html;
 49         location = /404.html {
 50         }
 51
 52         error_page 500 502 503 504 /50x.html;
 53         location = /50x.html {
 54         }
 55     }
 56
 57 # Settings for a TLS enabled server.
 58 #
 59 #    server {
 60 #        listen       443 ssl http2;
 61 #        listen       [::]:443 ssl http2;
 62 #        server_name  _;
 63 #        root         /usr/share/nginx/html;
 64 #
 65 #        ssl_certificate "/etc/pki/nginx/server.crt";
 66 #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
 67 #        ssl_session_cache shared:SSL:1m;
 68 #        ssl_session_timeout  10m;
 69 #        ssl_ciphers PROFILE=SYSTEM;
 70 #        ssl_prefer_server_ciphers on;
 71 #
 72 #        # Load configuration files for the default server block.
 73 #        include /etc/nginx/default.d/*.conf;
 74 #
 75 #        error_page 404 /404.html;
 76 #            location = /40x.html {
 77 #        }
 78 #
 79 #        error_page 500 502 503 504 /50x.html;
 80 #            location = /50x.html {
 81 #        }
 82 #    }
 83
 84 }
 85
vn flag
The first five lines of your main `server {` block are commented out.
alex avatar
jp flag
Are you referring to the server on line 59? 59 # server {
alex avatar
jp flag
wow~~!! solved it Thank you~ ceejayoz :D
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.