我已经使用Ruby/Sinatra应用程序成功地将nginx启动并运行良好。但是,我现在尝试从同一服务器上运行第二个应用程序,并注意到了一些奇怪的问题。首先,这是我的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
的请求?
listen fake.com | something.com:80
命令过滤器,而不是server_name
。 - Alexei Martchenko