最佳答案
我已经启动了 nginx 并运行了一个 Ruby/Sinatra 应用程序,一切正常。然而,我现在正在尝试从同一台服务器运行第二个应用程序,我注意到了一些奇怪的事情。首先,这是我的 nginx.conf:
pid /tmp/nginx.pid;
error_log /tmp/nginx.error.log;
events {
worker_connections 1024;
accept_mutex off;
}
http {
default_type application/octet-stream;
access_log /tmp/nginx.access.log combined;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
gzip on;
gzip_http_version 1.0;
gzip_proxied any;
gzip_min_length 500;
gzip_disable "MSIE [1-6]\.";
gzip_types text/plain text/xml text/css
text/comma-separated-values
text/javascript application/x-javascript
application/atom+xml;
upstream app {
server unix:/var/www/app/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
client_max_body_size 4G;
server_name FAKE.COM;
keepalive_timeout 5;
root /var/www/app/public;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /var/www/app/public;
}
}
}
68,0-1 B
注意 server_name
是如何设置为 FAKE.COM
的,但是服务器通过其他域名响应所有访问该服务器的主机。我如何才能使那个特定的服务器只响应对 FAKE.COM
的请求?