1: 修改win7操作系统的 hosts

  路径:C:\Windows\System32\drivers\etc\hosts

   在这个文件中添加

   192.168.93.131     www.mysc.com
   192.168.93.131     image.mysc.com

  添加这2行的意思是:以后在本机器上 访问www.mysc.com  或者 image.mysc.com 都是找 192.168.93.131(linux 服务器) 的80端口

  ps:实际上这个地方最好配置一个 dns的主机

 

2:在cmd 中输入 ipconfig /flushdns 让刚才的设置立即生效

 

3:修改centos操作系统的 hosts

    vim  /etc/hosts

    127.0.0.1     www.mysc.com
    127.0.0.1     image.mysc.com

     添加这2行的意思是:以后在本机器上 访问www.mysc.com  或者 image.mysc.com 都是找 127.0.0.1 本机的80端口

 

4  配置nginx

     进入nginx的安装目录

     whereis nginx  找到安装目录 cd 进入

    进入其中的conf 文件夹

   修改其中的 nginx.conf文件   vim nginx.conf

   找到文件的 # HTTPS server 节点   /# HTTPS server

   在其上 添加  include vhost/*.conf;    这里的意思是 这个文件 以后会把 vhost下的所有的。conf文件包含进来

 

5:在conf 文件夹子下面新建 vhost文件夹子  mkdir vhost

 

6:在vhost 中添加域名的解析文件

    vim www.mysc.com.conf

7:在其中添加:

  server {
    default_type 'text/html';
    charset utf-8;
    listen 80;
    autoindex on;
    server_name www.mysc.com;
    access_log /usr/local/nginx/logs/access.log combined;
    index index.html index.htm index.jsp index.php;
    #error_page 404 /404.html;
    if ( $query_string ~* ".*[\;'\<\>].*" ){
        return 404;
    }

    location / {
        proxy_pass http://127.0.0.1:8080/;
        add_header Access-Control-Allow-Origin *;
    }
}

 

8 重新启动nginx

  ../../sbin/nginx -s reload

 

9:去windows 本机测试一下 输入 http://www.mysc.com 是否导入到 tomcat下

 

10 再 去添加一个ftp服务器的域名

   进入 nginx的conf 中的vhost 创建 文件服务器的域名文件

   vim image.mysc.com.conf

 

11 在其中加入以下内容

  server {
    listen 80;
    autoindex off;
    server_name image.mysc.com;
    access_log /usr/local/nginx/logs/access.log combined;
    index index.html index.htm index.jsp index.php;
    #error_page 404 /404.html;
    if ( $query_string ~* ".*[\;'\<\>].*" ){
        return 404;
    }

    location ~ /(mmall_fe|mmall_admin_fe)/dist/view/* {
        deny all;
    }

    location / {
        root /ftpfile/;
        add_header Access-Control-Allow-Origin *;
    }
}

12: 保存重新启动nginx

  ../../sbin/nginx -s reload

 

13 测试

 

posted on 2017-08-16 07:13  快枪  阅读(255)  评论(0编辑  收藏  举报