title: "nginx: [emerg] "events" directive is not allowed here in /etc/nginx/sites-enabled/myapp.conf:1" Error in nginX
body: <p>I'm trying to make reverse load balancer proxy server with nginX.</p>
  
  <p>I created express server at <code>106.10.**.***:3000</code> and <code>106.10.**.***:4000</code></p>
  
  <p>When I ran <code>systemctl start nginx.service</code> it returned error like</p>
  
  <pre><code>Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
  root@airbnb-api:/etc/nginx/sites-enabled# systemctl start nginx.service
  </code></pre>
  
  <p>so I tried systemctl status nginx.service which is on below</p>
  
  <pre><code>events { }
  
  http {
      upstream backend {
          server 106.10.**.***:3000;
          server 106.10.**.***:4000;
      }
  
      server {
          location / {
              proxy_pass http://backend;
          }
      }
  }
  
  </code></pre>
  
  <pre><code>● nginx.service - A high performance web server and a reverse proxy server
     Loaded: loaded (/lib/systemd/system/nginx.service; disabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Tue 2019-10-29 00:22:20 KST; 7s ago
       Docs: man:nginx(8)
    Process: 3634 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=1/FAILURE)
  
  Oct 29 00:22:20 airbnb-api systemd[1]: Starting A high performance web server and a reverse proxy server...
  Oct 29 00:22:20 airbnb-api nginx[3634]: nginx: [emerg] "events" directive is not allowed here in /etc/nginx/sites-enabled/myapp.conf:1
  Oct 29 00:22:20 airbnb-api nginx[3634]: nginx: configuration file /etc/nginx/nginx.conf test failed
  Oct 29 00:22:20 airbnb-api systemd[1]: nginx.service: Control process exited, code=exited status=1
  Oct 29 00:22:20 airbnb-api systemd[1]: Failed to start A high performance web server and a reverse proxy server.
  Oct 29 00:22:20 airbnb-api systemd[1]: nginx.service: Unit entered failed state.
  Oct 29 00:22:20 airbnb-api systemd[1]: nginx.service: Failed with result 'exit-code'.
  </code></pre>
  
  <p>I've checked <code>106.10.**.***:3000</code> <code>106.10.**.***:4000</code> and they worked well.</p>
  
  <p>Noting returned when trying <code>sudo lsof -i:80</code></p>
  
  <p>both code returned to be successful</p>
  
  <pre><code>nginx -t -c /etc/nginx/sites-available/myapp.conf
  nginx -t -c /etc/nginx/sites-enabled/myapp.conf
  </code></pre>