首页 > 其他 > 详细

nginx配置虚拟机 端口号 域名 区分虚拟机

时间:2017-02-18 12:11:30      阅读:357      评论:0      收藏:0      [点我收藏+]

nginx配置虚拟机

在/usr/local/nginx/conf目录下nginx.conf文件是nginx的配置文件。

技术分享

 

一、通过端口号区分虚拟机

在nginx.conf文件中添加一个Service节点,修改端口号:
 
server {
        listen       80;
        server_name  localhost;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        location / {
            root   html80;
            index  index.html index.htm;
        }
   }
 
server {
        listen       81;
        server_name  localhost;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        location / {
            root   html81;
            index  index.html index.htm;
        }
   } 

二、通过域名区分虚拟机

server {
        listen       80;
        server_name  test1.nginx.com;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        location / {
            root   html-test3;
            index  index.html index.htm;
        }
   }
 
server {
        listen       80;
        server_name  test2.nginx.com;
 
        #charset koi8-r;
 
        #access_log  logs/host.access.log  main;
 
        location / {
            root   html-test3;
            index  index.html index.htm;
        }
   }
[root@localhost sbin]# ./nginx -s reload

nginx配置虚拟机 端口号 域名 区分虚拟机

原文:http://www.cnblogs.com/shaoing/p/6412643.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!