在site.name和www.site.name上打开站点

时间:2013-10-17 11:41:36

标签: nginx

我试图按照the manualserver_name .site.name)中的说明实现这一目标,但它似乎不起作用(404 Not found)。我可以不重定向吗?

这是配置。

server {
    listen 80;
    listen 443 ssl;
    server_name .site.name;

    ssl_certificate     certs/mshop-production.crt;
    ssl_certificate_key certs/mshop-production.key;
    passenger_set_cgi_param HTTP_X_FORWARDED_PROTO $scheme;

    error_log /var/log/nginx/mshop-production.error.log error;
    access_log /var/log/nginx/mshop-production.access.log;

    root /home/deployer/apps/production/mshop/current/public;
    passenger_enabled on;
    rails_env production;

    gzip on;
    gzip_types application/x-javascript application/javascript text/javascript text/css;

    client_max_body_size 50m;

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires 1M;
    }
}

2 个答案:

答案 0 :(得分:2)

为什么不修改域名服务器中的A查询记录?

我认为这对你来说更简单。

答案 1 :(得分:1)

 server_name server.name www.server.name;

会这样做。您也可以使用通配符

 server_name server.name *.server.name;