Nginx 监听多个域名配置样例

通过nginx 配置,监听不同端口、不同域名来源 映射到不同的目录下。示例如下:

# 监控www域名
server {
    listen       80;
    server_name  www.domain1.com;

    #charset koi8-r;
    #access_log  logs/host.access.log  main;

    root   html/folder1; #指定该域名对应的根目录
    location / {
        root   html/folder1;
        index  index.html index.htm;
    }
}

# 监听@配置的域名
server {
    listen       80;
    server_name  domain1.com;

    #charset koi8-r;
    #access_log  logs/host.access.log  main;

    root   html/folder2; #指定该域名对应的根目录
    location / {
        root   html/folder2;
        index  index.html index.htm;
    }
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章