Nginx Configuration

Nginx Configure

sudo apt-get install nginx

sudo vi /etc/nginx/sites-available/default

Default Configure

upstream app {

  # Path to Puma SOCK file, as defined previously

  server unix:/home/deployer/xphabib/shared/tmp/sockets/puma.sock fail_timeout=0;

}


server {

  listen 80;

  server_name localhost;

  root /home/deployer/xphabib/current/public;

  try_files $uri/index.html $uri @app;


  location / {

    proxy_set_header X-Forwarded-Proto $scheme;

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    proxy_set_header X-Real-IP $remote_addr;

    proxy_set_header Host $host;

    proxy_redirect off;

    proxy_http_version 1.1;

    proxy_set_header Connection '';

    proxy_pass http://app;

  }


  location ~ ^/(assets|fonts|system)/|favicon.ico|robots.txt {

    gzip_static on;

    expires max;

    add_header Cache-Control public;

  }


  error_page 500 502 503 504 /500.html;

  client_max_body_size 4G;

  keepalive_timeout 10;

}  

Nginx folder permission error: (Nginx need to have +x access on all directories leading to the site's root directory)

chmod +x /home/ 

chmod +x /home/username

chmod +x /home/username/siteroot

Error Log and Access Log
System Log Directory: /var/log/nginx/ 

tail -f /var/log/nginx/access.log

tail -f /var/log/nginx/error.log