首頁  >  文章  >  後端開發  >  nginx配置多個站點的問題?

nginx配置多個站點的問題?

WBOY
WBOY原創
2016-08-25 10:37:181078瀏覽

我用nginx配置兩個站點,一個站點要配置成https訪問,一個是http來訪問?

server {

<code>    listen       443;
    server_name  www.gzjjhd.com;
    
    
    ssl on;
    ssl_certificate E:/webserver/nginx/sslkey/wosign.com.crt;
    ssl_certificate_key E:/webserver/nginx/sslkey/wosign.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers  AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
    ssl_prefer_server_ciphers on;


    location / {
        root   E:/www/jsd;
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location ~ \.php$ {
        root           E:/www/jsd;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

server {
    listen       80;
    server_name app.gzjjhd.com;

    location / {
        root   E:/www/HDWeb;
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
    
    include E:/www/HDWeb/rewrite.conf;
    
    location ~ \.php$ {
        root           E:/www/HDWeb;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
</code>

我這樣配置完,app.gzjjhd.com 也變成 https://appgzjjhd.com 來訪問。但是我不要這樣。我要http://app.gzjjhd.com 請教各位大神如何修改!

回覆內容:

我用nginx配置兩個站點,一個站點要配置成https訪問,一個是http來訪問?

server {

<code>    listen       443;
    server_name  www.gzjjhd.com;
    
    
    ssl on;
    ssl_certificate E:/webserver/nginx/sslkey/wosign.com.crt;
    ssl_certificate_key E:/webserver/nginx/sslkey/wosign.com.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers  AESGCM:ALL:!DH:!EXPORT:!RC4:+HIGH:!MEDIUM:!LOW:!aNULL:!eNULL;
    ssl_prefer_server_ciphers on;


    location / {
        root   E:/www/jsd;
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    location ~ \.php$ {
        root           E:/www/jsd;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

server {
    listen       80;
    server_name app.gzjjhd.com;

    location / {
        root   E:/www/HDWeb;
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
    
    include E:/www/HDWeb/rewrite.conf;
    
    location ~ \.php$ {
        root           E:/www/HDWeb;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
</code>

我這樣配置完,app.gzjjhd.com 也變成 https://appgzjjhd.com 來訪問。但是我不要這樣。我要http://app.gzjjhd.com 請教各位大神如何修改!

分別用兩個站點設定檔

原來是我的443埠被佔用了

設定多個站點, 也就是虛擬主機的意思, 同一個server,載入多個站點, 在ngixn中設定虛擬主機,直接在主設定檔新增一個server{} 就可以了, 仿照他自帶的sever裡面的參數

<code>78    server {
79        listen 80;
80    #    listen somename:8080;
81        server_name www.xuping.com;
82        root /usr/share/nginx/xuping;
83        index index.html index.htm;
84    
85        location / {
86            try_files $uri $uri/ =404;
87        }
88        location ~ \.php$ {
89            fastcgi_split_path_info ^(.+\.php)(/.+)$;
90            # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
91        
92            # With php5-cgi alone:
93        #    fastcgi_pass 127.0.0.1:9000;
94        #    # With php5-fpm:
95            fastcgi_pass unix:/var/run/php5-fpm.sock;
96            fastcgi_index index.php;
97            include fastcgi_params;
98        }
99    </code>

100 # deny access to .htaccess files, if Apache's document root
101 # concurs with nginx's one
102 #
103 location ~ /.ht {
102 #
}

直接在這裡制定連接埠號碼和規則就可以了。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn