域名被nginx拒绝

时间:2015-05-27 07:23:04

标签: ruby-on-rails ruby web nginx

我有一台服务器运行一个非常简单的rails应用程序。它已nginx设置为侦听端口80,它会将请求转发到unicorn下的(Rails.root)/tmp/unicorn.sock套接字文件。

我从domain.com购买了一个域名,并将其指向我服务器的地址=。

e.g。

Domain: mydomain.com -> Server: 110.56.45.12

当我直接点击服务器时,通过访问浏览器中的110.56.45.12ssh - 进入框并运行curl 127.0.0.1,一切正常。我认为这是因为这两个操作都在端口80上运行,而nginx会回送正确的内容。

但是,当我尝试使用公共域名domain.com或尝试使用curl localhost时,我会获得经典"我们很抱歉,但出了点问题。" rails page。

我检查了导航production日志,那里什么都没有。然后,我在nginx处检查了/var/log/nginx/error.log错误日志,但只获得了

2015/05/27 07:01:24 [error] 20041#0: *143 connect() to unix:/home/jeeves/my_app/tmp/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: mydomain.com, request: "GET / HTTP/1.1", upstream: "http://unix:/home/jeeves/my_app/tmp/unicorn.sock:/", host: "localhost"

我的服务器是否有任何理由拒绝该连接?

谢谢!

修改

这是我的nginx.conf文件

user  jeeves;
worker_processes  1;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {

    ##
    # Basic Settings
    ##

    sendfile on;
    tcp_nopush on;
    tcp_nodelay off;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    server_tokens off;

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    ##
    # Logging Settings
    ##

    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  /var/log/nginx/access.log  main;
    error_log /var/log/nginx/error.log;

    ##
    # Gzip Settings
    ##

    gzip on;
    gzip_disable "msie6";
    gzip_http_version 1.1;
    gzip_proxied any;
    gzip_min_length 500;
    gzip_types text/plain text/xml text/css
      text/comma-separated-values text/javascript
      application/x-javascript application/atom+xml;

    ##
    # Unicorn Rails
    ##

    upstream unicorn {  
      server unix:/home/jeeves/my_app/tmp/unicorn.sock fail_timeout=0;
    }

    ##
    # Includes
    ##

    include /etc/nginx/sites-enabled/*;
}

最后一行包含sites-enabled目录中的所有内容,该目录只有一个文件 - mydomain.com

server {
  listen 80;
  server_name mydomain.com; # Replace this with your site's domain.

  keepalive_timeout 300;

  client_max_body_size 4G;

  # Set this to the public folder location of your Rails application.
  root /home/jeeves/my_app/public; 

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

  location @unicorn {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X-Forwarded_Proto $scheme;
          proxy_redirect off;
          # This passes requests to unicorn, as defined in /etc/nginx/nginx.conf
          proxy_pass http://unicorn;
          proxy_read_timeout 300s;
          proxy_send_timeout 300s;
  }

  # You can override error pages by redirecting the requests to a file in your
  # application's public folder, if you so desire:
  error_page 500 502 503 504 /500.html;
}

0 个答案:

没有答案
相关问题