如何让多个网站在Nginx上运行

时间:2016-06-11 22:06:24

标签: ssl nginx

我使用Nginx在Ubuntu上成功建立了一个站点,但现在我想在服务器上添加第二个站点。第一个站点通过Let's Encrypt拥有SSL,但第二个站点没有SSL。现在我可以显示的是两个不同URI的第一个站点。我哪里做错了?我的/ sites-enabled /文件夹中有两个站点。

第一个网站(有效的网站):

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    return 301 https://$host$request_uri;
}
server {
    listen 443 ssl spdy;
    listen [::]:443 ssl spdy;
    ssl_certificate /etc/letsencrypt/live/example1.com/cert.pem;
    ssl_certificate_key /etc/letsencrypt/live/example1.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example1.com/cert.pem;
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 208.67.222.222 208.67.220.220;

    root /var/www/example1.com/web;
    index index.html index.htm index.php index.nginx-debian.html

    server_name example1.com www.example1.com;
    include hhvm.conf;
    include global/wordpress.conf;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9000;
    }
    location ~* /\.\./ {
        deny all;
        return 404;
    }
}

/ etc / nginx / sites-enabled下的第二个站点:

server {
    listen 80;
    listen [::]:80;
    return 301 http://$host$request_uri;

    resolver 208.67.222.222 208.67.220.220;

    root /var/www/example2.com/web;
    index index.html index.htm index.php index.nginx-debian.html

    server_name example2.com www.example2.com;
    include hhvm.conf;
    include global/wordpress.conf;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass 127.0.0.1:9000;
    }
    location ~* /\.\./ {
        deny all;
        return 404;
    }
}

0 个答案:

没有答案