title: How can I use nginx with adonis?
body: <p>I'm try to make a deploy of one api adonis and I'm trying to use nginx to enable external access to my http requests.</p>
  
  <p>I install nginx and go in ssh I go to:</p>
  
  <pre><code>cd /etc/nginx
  vi nginx.conf
  </code></pre>
  
  <p>So, I put this code:</p>
  
  <pre><code>#user  nobody;
  worker_processes  1;
  
  #error_log  logs/error.log;
  #error_log  logs/error.log  notice;
  #error_log  logs/error.log  info;
  
  #pid        logs/nginx.pid;
  
  
  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  logs/access.log  main;
  
      sendfile        on;
      #tcp_nopush     on;
  
      #keepalive_timeout  0;
      keepalive_timeout  65;
  
      #gzip  on;
  
  
      # another virtual host using mix of IP-, name-, and port-based configuration
      #
      #server {
      #    listen       8000;
      #    listen       somename:8080;
      #    server_name  somename  alias  another.alias;
  
      #    location / {
      #        root   html;
      #        index  index.html index.htm;
      #    }
      #}
  
      server {
          listen 80;
  
          server_name knowhowexpressapp.com ;
  
          location / {
              proxy_pass http://localhost:3333;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection 'upgrade';
              proxy_set_header Host $host;
              proxy_set_header X-Real-IP $remote_addr;
              proxy_set_header X-Forwarded-Proto $scheme;
              proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_cache_bypass $http_upgrade;
          }
      }
  
  
      # HTTPS server
      #
      #server {
      #    listen       443 ssl;
      #    server_name  localhost;
  
      #    ssl_certificate      cert.pem;
      #    ssl_certificate_key  cert.key;
  
      #    ssl_session_cache    shared:SSL:1m;
      #    ssl_session_timeout  5m;
  
      #    ssl_ciphers  HIGH:!aNULL:!MD5;
      #    ssl_prefer_server_ciphers  on;
  
      #    location / {
      #        root   html;
      #        index  index.html index.htm;
      #    }
      #}
  
  }
  </code></pre>
  
  <p>In server name I put the domain;
  In port I put 3333 because is the port that I put in .env;</p>
  
  <p>I start nginx:</p>
  
  <pre><code>cd /usr/bin/etc/nginx
  nginx
  </code></pre>
  
  <p>Check if nginx is running:</p>
  
  <pre><code>[root@knowhowexpressapp etc]# ps aux | grep nginx
  root      14143  0.0  0.0  55320  1028 ?        Ss   11:41   0:00 nginx: master process nginx
  nginx     14144  0.0  0.0  55708  1936 ?        S    11:41   0:00 nginx: worker process
  root      14188  0.0  0.0 112712   964 pts/2    S+   11:42   0:00 grep --color=auto nginx
  </code></pre>
  
  <p>My .env archive:</p>
  
  <pre><code>HOST=ip from my server
  PORT=3333
  NODE_ENV=production
  APP_NAME=AdonisJs
  APP_URL=http://${HOST}:${PORT}
  CACHE_VIEWS=false
  APP_KEY=GPhustNKtbIlrxawTZa6xQTIkHcjBXFr
  DB_CONNECTION=pg
  DB_HOST=localhost
  DB_PORT=5432
  DB_USER=postgres
  DB_PASSWORD=xxxx
  DB_DATABASE=xxx
  HASH_DRIVER=bcrypt
  </code></pre>
  
  <p>So, i check pm2 and my server is running:</p>
  
  <pre><code>⇆ PM2+ activated 
  ┌─────┬───────────┬─────────────┬─────────┬─────────┬──────────┬────────┬──────┬───────────┬──────────┬──────────┬──────────┬──────────┐
  │ id  │ name      │ namespace   │ version │ mode    │ pid      │ uptime │ ↺    │ status    │ cpu      │ mem      │ user     │ watching │
  ├─────┼───────────┼─────────────┼─────────┼─────────┼──────────┼────────┼──────┼───────────┼──────────┼──────────┼──────────┼──────────┤
  │ 0   │ server    │ default     │ 4.1.0   │ fork    │ 12586    │ 16m    │ 34   │ online    │ 0%       │ 41.0mb   │ root     │ disabled │
  </code></pre>
  
  <p>But when i try to access my api i'm getting:</p>
  
  <blockquote>
    <p>Could not get any response There was an error connecting to
    <a href="https://knowhowexpressapp.com/login" rel="nofollow noreferrer">https://knowhowexpressapp.com/login</a>.</p>
  </blockquote>
  
  <p>My server is centos 7</p>
  
  <p>My api is only running if i put the <a href="http://ipfrommyserver" rel="nofollow noreferrer">http://ipfrommyserver</a> but when i try to access the domain i receive error.</p>