Nginx用ip覆盖我的域名

时间:2014-07-05 10:18:03

标签: nginx dns vps

我在一个VPS下运行了2个站点。此外,我还指向指向该VPS的域名。我可以通过域名打开我的网站,但在打开后,域名会被浏览器地址栏中的VPS ip覆盖。

这里有一些配置文件:

的/ etc /主机

127.0.0.1 localhost ubuntu1

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

两个站点的nginx.conf几乎相同:

upstream unicorn {
  server unix:/tmp/unicorn.example1.sock fail_timeout=0;
}

server {
  server_name example1.com www.example1.com;
  listen 80;
  listen [::]:80 ipv6only=on;
  root /home/ubuntu/apps/exapmle1/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;
}

和第二:

upstream unicorn {
  server unix:/tmp/unicorn.example2.sock fail_timeout=0;
}

server {
  server_name example2.com www.example2.com;
  listen 80;
  listen [::]:80 ipv6only=on;
  root /home/ubuntu/apps/exapmle2/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;
}

请让我知道我在哪里做错了。

0 个答案:

没有答案