After deploying, I see the default nginx "It works!"

I have deployed a rails application from Capistrano to a VPS and when I try to access it using "" I see the standard Nginx "It works!" p.

I tried to delete the file index.html

from the folder /var/www

, now I see it as a folder: apps

, log

and tmp


In nginx.conf

I have:

user nginx web;

pid /var/run/;
error_log /var/www/log/nginx.error.log;

events {
  worker_connections 1024;
  accept_mutex off;
  use epoll;

http {
  include mime.types;
  types_hash_max_size 2048;
  server_names_hash_bucket_size 64;
  default_type application/octet-stream;
  access_log /var/www/log/nginx.access.log combined;
  sendfile on;
  tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
  tcp_nodelay off; # on may be better for some Comet/long-poll stuff

  gzip on;
  gzip_http_version 1.0;
  gzip_proxied any;
  gzip_min_length 0;
  gzip_vary on;
  gzip_disable "MSIE [1-6]\.";
  gzip_proxied expired no-cache no-store private auth;
  gzip_comp_level 9;
  gzip_types text/plain text/xml text/css
             text/javascript application/x-javascript

  upstream app_server {
    server unix:/var/www/apps/APP_NAME/socket/.unicorn.sock fail_timeout=0;

  server {

    pagespeed on;
    pagespeed FileCachePath /var/ngx_pagespeed_cache;

    location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
      add_header "" "";

    location ~ "^/ngx_pagespeed_static/" { }
    location ~ "^/ngx_pagespeed_beacon$" { }

    location /ngx_pagespeed_statistics {
      allow; allow; deny all;

    location /ngx_pagespeed_global_statistics {
      allow; allow; deny all;

    pagespeed MessageBufferSize 100000;

    location /ngx_pagespeed_message {
      allow; allow; deny all;

    location /pagespeed_console {
      allow; allow; deny all;

    charset utf-8;
    listen 80 default deferred; # for Linux
    client_max_body_size 4G;
    server_name _;
    keepalive_timeout 5;
    root /var/www/apps/APP_NAME/current/public;
    try_files $uri/index.html $uri.html $uri @app;

    location ~ ^/(assets)/  {
      root /var/www/apps/APP_NAME/current/public;
      expires max;
      add_header Cache-Control public;

    location @app {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://app_server;

    error_page 500 502 503 504 /500.html;
    location = /500.html {
      root /var/www/apps/APP_NAME/current/public;


Am I missing something in nginx.conf

or in other files?

Also, when I stop the nginx server it doesn't make sense, I see the same page.

I am not good at deploying applications to the server, this is my first time without Heroku, so I donโ€™t know what exactly you need to know to help with my problem. So, if you need more information, ask, I'll add it to the question.



source to share

2 answers

So I found a solution from this answer . The problem was with the Apache web server running in the background and preventing Nginx from running on 80 ports.

I stopped the Apache server and restarted Nginx and now everything works fine:

sudo apachectl stop
sudo restart nginx




You should use a passenger and set something like this in nginx config:

    http {
        passenger_root /home/deployer/.rvm/gems/ruby-1.9.3-p327/gems/passenger-3.0.18;
        passenger_ruby /home/deployer/.rvm/wrappers/ruby-1.9.3-p327/ruby;


or use an HTTP server for Rack like Unicorn and set in nginx config:

upstream app_server {
  server unix:/path/to/.unicorn.sock fail_timeout=0;

server {
  proxy_pass http://app_server;




All Articles