nginx虛擬主機

區分不一樣的網站有三種方式:
一、ip區分
二、端口區分
三、域名區分html

基於ip的虛擬主機配置
    server {
        listen       80;
        server_name  192.168.11.181;
        
        location / {
            root   html-181;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    server {
        listen       80;
        server_name  192.168.11.182;
        
        location / {
            root   html-182;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

基於端口的虛擬主機
    server {
        listen       80;
        server_name  192.168.11.182;
        
        location / {
            root   html-182;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
    server {
        listen       81;
        server_name  192.168.11.182;
        
        location / {
            root   html-81;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }    
基於域名的虛擬主機
    server {
        listen       80;
        server_name  www.fuyi.com;
        
        location / {
            root   html-181;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    } 
    server {
        listen       80;
        server_name  m.fuyi.com;
        
        location / {
            root   html-182;
            index  index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
相關文章
相關標籤/搜索