我已经安装了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
?
listen fake.com | something.com:80
命令过滤器,不是server_name
。