1

我有一个使用独角兽在 nginx 服务器后面的服务上运行的应用程序。

如果我访问http://server.com我得到了应用程序,启动并运行......但我仍然可以访问端口 8080 上的应用程序,如http://server.com:8080但这一次,没有资产(这是由 nginx 服务)

如何阻止直接访问我的产品上的端口 8080。服务器?

服务器是 Ubuntu 12.04

nginx.conf

upstream unicorn {
  server 127.0.0.1:8080;
}

server {
  listen 80 default deferred;
  # server_name example.com; 
  root /home/deploy/current/public;

  location ^~ /assets/ {
    gzip_static on;
    expires max;
    add_header Cache-Control public;
  }

  try_files $uri/index.html $uri @unicorn;
  location @unicorn {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://unicorn;
  }

  error_page 500 502 503 504 /500.html;
  client_max_body_size 4G;
  keepalive_timeout 10;
}
4

1 回答 1

1

让 unicorn 和 nginx 使用域套接字。对于 nginx:

upstream unicorn {
  server unix:/path/to/socket fail_timeout=0;
}

然后将 '-l /path/to/socket' 传递给 unicorn,或更改您的 unicorn 配置文件:

listen '/path/to/socket'
于 2012-08-18T20:21:46.967 回答