ruby-on-rails-部署后,我看到了标准的nginx的“有效!”

前端之家收集整理的这篇文章主要介绍了ruby-on-rails-部署后,我看到了标准的nginx的“有效!” 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我已经使用Capistrano将Rails应用程序部署到了VPS,当我尝试通过“ APP_NAME.com”访问它时,我看到了标准Nginx的“有效!”页.

我尝试从/ var / www文件夹中删除index.html文件,现在可以看到其中的文件夹:应用程序,日志和tmp.

Nginx.conf中,我有:

user Nginx web;

pid /var/run/Nginx.pid;
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/comma-separated-values
             text/javascript application/x-javascript
             application/atom+xml;

  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 127.0.0.1; allow 5.228.169.73; deny all;
    }

    location /ngx_pagespeed_global_statistics {
      allow 127.0.0.1; allow 5.228.169.73; deny all;
    }

    pagespeed MessageBufferSize 100000;

    location /ngx_pagespeed_message {
      allow 127.0.0.1; allow 5.228.169.73; deny all;
    }

    location /pagespeed_console {
      allow 127.0.0.1; allow 5.228.169.73; 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;
    }
  }
}

我在Nginx.conf或其他文件中缺少什么吗?

另外,当我停止Nginx服务器时,这没有任何意义,我会看到同一页面.

我不太擅长将应用程序部署到服务器上,这是我第一次没有Heroku,所以我不知道您需要知道什么来帮助解决我的问题.因此,如果您需要任何其他信息,请询问,我将其添加到问题中.

谢谢!

最佳答案
因此,我找到了从this answer开始的解决方案.问题出在Apache Web服务器上,该服务器在后台运行并阻止Nginx在80端口上运行.

我已经停止了Apache服务器并重新启动Nginx,现在一切正常.

sudo apachectl stop
sudo restart Nginx
原文链接:https://www.f2er.com/nginx/532254.html

猜你在找的Nginx相关文章